CC-3718: Please enable user to input the mail server settings
-done
This commit is contained in:
parent
7d4851573f
commit
ca8187c9c2
10 changed files with 352 additions and 82 deletions
|
@ -12,15 +12,44 @@ class Application_Model_Email {
|
|||
*/
|
||||
public static function send($subject, $message, $tos, $from = null)
|
||||
{
|
||||
$mailServerConfigured = Application_Model_Preference::GetMailServerConfigured() == true ? true : false;
|
||||
if ($mailServerConfigured) {
|
||||
$username = Application_Model_Preference::GetMailServerEmailAddress();
|
||||
$password = Application_Model_Preference::GetMailServerPassword();
|
||||
$mailServer = Application_Model_Preference::GetMailServer();
|
||||
$mailServerPort = Application_Model_Preference::GetMailServerPort();
|
||||
if (!empty($mailServerPort)) {
|
||||
$port = Application_Model_Preference::GetMailServerPort();
|
||||
}
|
||||
|
||||
$config = array(
|
||||
'auth' => 'login',
|
||||
'ssl' => 'ssl',
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
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);
|
||||
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetSystemEmail());
|
||||
|
||||
|
||||
foreach ((array) $tos as $to) {
|
||||
$mail->addTo($to);
|
||||
}
|
||||
|
||||
$mail->send();
|
||||
if ($mailServerConfigured) {
|
||||
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetMailServerEmailAddress());
|
||||
$mail->send($transport);
|
||||
} else {
|
||||
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetSystemEmail());
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -887,6 +887,46 @@ class Application_Model_Preference
|
|||
public static function GetSystemEmail() {
|
||||
return self::GetValue("system_email");
|
||||
}
|
||||
|
||||
public static function SetMailServerConfigured($value) {
|
||||
self::SetValue("mail_server_configured", $value, false);
|
||||
}
|
||||
|
||||
public static function GetMailServerConfigured() {
|
||||
return self::GetValue("mail_server_configured");
|
||||
}
|
||||
|
||||
public static function SetMailServer($value) {
|
||||
self::SetValue("mail_server", $value, false);
|
||||
}
|
||||
|
||||
public static function GetMailServer() {
|
||||
return self::GetValue("mail_server");
|
||||
}
|
||||
|
||||
public static function SetMailServerEmailAddress($value) {
|
||||
self::SetValue("mail_server_email_address", $value, false);
|
||||
}
|
||||
|
||||
public static function GetMailServerEmailAddress() {
|
||||
return self::GetValue("mail_server_email_address");
|
||||
}
|
||||
|
||||
public static function SetMailServerPassword($value) {
|
||||
self::SetValue("mail_server_password", $value, false);
|
||||
}
|
||||
|
||||
public static function GetMailServerPassword() {
|
||||
return self::GetValue("mail_server_password");
|
||||
}
|
||||
|
||||
public static function SetMailServerPort($value) {
|
||||
self::SetValue("mail_server_port", $value, false);
|
||||
}
|
||||
|
||||
public static function GetMailServerPort() {
|
||||
return self::GetValue("mail_server_port");
|
||||
}
|
||||
/* User specific preferences end */
|
||||
|
||||
public static function ShouldShowPopUp(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue