Merge branch 'saas-dev' into saas-dev-lang-tz-setup
This commit is contained in:
commit
7839a712e6
|
@ -12,65 +12,8 @@ class Application_Model_Email
|
||||||
*/
|
*/
|
||||||
public static function send($subject, $message, $tos, $from = null)
|
public static function send($subject, $message, $tos, $from = null)
|
||||||
{
|
{
|
||||||
$mailServerConfigured = Application_Model_Preference::GetMailServerConfigured() == true ? true : false;
|
|
||||||
$mailServerRequiresAuth = Application_Model_Preference::GetMailServerRequiresAuth() == true ? true : false;
|
|
||||||
$success = true;
|
|
||||||
|
|
||||||
if ($mailServerConfigured) {
|
return mail($tos, $subject, $message);
|
||||||
$mailServer = Application_Model_Preference::GetMailServer();
|
|
||||||
$mailServerPort = Application_Model_Preference::GetMailServerPort();
|
|
||||||
if (!empty($mailServerPort)) {
|
|
||||||
$port = $mailServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mailServerRequiresAuth) {
|
|
||||||
$username = Application_Model_Preference::GetMailServerEmailAddress();
|
|
||||||
$password = Application_Model_Preference::GetMailServerPassword();
|
|
||||||
|
|
||||||
$config = array(
|
|
||||||
'auth' => 'login',
|
|
||||||
'ssl' => 'ssl',
|
|
||||||
'username' => $username,
|
|
||||||
'password' => $password
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$config = array(
|
|
||||||
'ssl' => 'tls'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($port)) {
|
|
||||||
$config['port'] = $port;
|
|
||||||
}
|
|
||||||
|
|
||||||
$transport = new Zend_Mail_Transport_Smtp($mailServer, $config);
|
|
||||||
}
|
|
||||||
|
|
||||||
$mail = new Zend_Mail('utf-8');
|
|
||||||
$mail->setSubject($subject);
|
|
||||||
$mail->setBodyText($message);
|
|
||||||
|
|
||||||
foreach ((array) $tos as $to) {
|
|
||||||
$mail->addTo($to);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mailServerConfigured) {
|
|
||||||
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetMailServerEmailAddress());
|
|
||||||
try {
|
|
||||||
$mail->send($transport);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetSystemEmail());
|
|
||||||
try {
|
|
||||||
$mail->send();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $success;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
<?php echo $this->element->getElement('csrf') ?>
|
<?php echo $this->element->getElement('csrf') ?>
|
||||||
|
|
||||||
<?php if (Application_Model_Preference::GetEnableSystemEmail()): ?>
|
<?php if (Application_Model_Preference::GetEnableSystemEmail()): ?>
|
||||||
<dt id="reset-label" class="hidden"> </dt>
|
<dt id="reset-label" class="hidden"> </dt>
|
||||||
<dd id="reset-element" class="text-right">
|
<dd id="reset-element" class="text-right">
|
||||||
<a href="<?php echo $this->baseUrl('login/password-restore'); ?>" class="link reset"><?php echo _("Reset password") ?></a>
|
<a href="<?php echo $this->baseUrl('login/password-restore'); ?>" class="link reset"><?php echo _("Reset password") ?></a>
|
||||||
</dd>
|
</dd>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php echo $this->element->getElement('captcha') ?>
|
<?php echo $this->element->getElement('captcha') ?>
|
||||||
<dt id="submit-label"> </dt>
|
<dt id="submit-label"> </dt>
|
||||||
|
|
Loading…
Reference in New Issue