From 4026867535e27230ffc89c999e5b16e7f0fc6345 Mon Sep 17 00:00:00 2001 From: SintezCode Date: Fri, 1 Sep 2017 17:02:55 +0300 Subject: [PATCH 1/3] Improve mail options Add custom from, replyto options for snippets --- .../login/model/login/login.class.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/components/login/model/login/login.class.php b/core/components/login/model/login/login.class.php index 085b3e4b..13dd8bc2 100644 --- a/core/components/login/model/login/login.class.php +++ b/core/components/login/model/login/login.class.php @@ -156,19 +156,23 @@ public function sendEmail($email,$name,$subject,$properties = array()) { if (!empty($properties['tplAlt'])) { $msgAlt = $this->getChunk($properties['tplAlt'],$properties,$properties['tplType']); } - - + + $properties['emailFromName'] = $this->modx->getOption('emailFromName',$properties,$this->modx->getOption('site_name')); + $properties['emailFrom'] = $this->modx->getOption('emailFrom',$properties,$this->modx->getOption('emailsender')); + $properties['emailReplyToName'] = $this->modx->getOption('emailReplyToName',$properties,$properties['emailFromName']); + $properties['emailReplyTo'] = $this->modx->getOption('emailReplyTo',$properties,$properties['emailFrom']); + $this->modx->getService('mail', 'mail.modPHPMailer'); $this->modx->mail->set(modMail::MAIL_BODY, $msg); - $this->modx->mail->set(modMail::MAIL_FROM, $this->modx->getOption('emailsender')); - $this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('site_name')); - $this->modx->mail->set(modMail::MAIL_SENDER, $this->modx->getOption('emailsender')); + $this->modx->mail->set(modMail::MAIL_FROM, $properties['emailFrom']); + $this->modx->mail->set(modMail::MAIL_FROM_NAME, $properties['emailFromName']); + $this->modx->mail->set(modMail::MAIL_SENDER, $properties['emailFrom']); $this->modx->mail->set(modMail::MAIL_SUBJECT, $subject); if (!empty($msgAlt)) { $this->modx->mail->set(modMail::MAIL_BODY_TEXT, $msgAlt); } $this->modx->mail->address('to', $email, $name); - $this->modx->mail->address('reply-to', $this->modx->getOption('emailsender')); + $this->modx->mail->address('reply-to', $properties['emailReplyTo'], $properties['emailReplyToName']); $this->modx->mail->setHTML(true); if ($this->inTestMode) return true; $sent = $this->modx->mail->send(); @@ -306,4 +310,4 @@ public function getEventResult($rs) { } return $success; } -} \ No newline at end of file +} From c4a2853c68ddf8b76ba2a9cd2c8e7e86c5a24725 Mon Sep 17 00:00:00 2001 From: SintezCode Date: Fri, 1 Sep 2017 17:06:07 +0300 Subject: [PATCH 2/3] Add from, replyto options --- core/components/login/controllers/web/ForgotPassword.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/components/login/controllers/web/ForgotPassword.php b/core/components/login/controllers/web/ForgotPassword.php index 6ebcf793..b3fd6246 100644 --- a/core/components/login/controllers/web/ForgotPassword.php +++ b/core/components/login/controllers/web/ForgotPassword.php @@ -221,6 +221,10 @@ public function sendPasswordResetEmail() { $emailProperties['tpl'] = $this->getProperty('emailTpl'); $emailProperties['tplAlt'] = $this->getProperty('emailTplAlt',''); $emailProperties['tplType'] = $this->getProperty('emailTplType'); + $emailProperties['emailFromName'] = $this->getProperty('emailFromName'); + $emailProperties['emailFrom'] = $this->getProperty('emailFrom'); + $emailProperties['emailReplyToName'] = $this->getProperty('emailReplyToName'); + $emailProperties['emailReplyTo'] = $this->getProperty('emailReplyTo'); /* now set new password to cache to prevent middleman attacks */ $this->modx->cacheManager->set('login/resetpassword/'.$fields['username'],$password); @@ -247,4 +251,4 @@ public function checkForRedirect() { return !empty($redirectTo); } } -return 'LoginForgotPasswordController'; \ No newline at end of file +return 'LoginForgotPasswordController'; From 278d3675027b0422a55aa61516223ca2fd4d6fa2 Mon Sep 17 00:00:00 2001 From: SintezCode Date: Fri, 1 Sep 2017 17:09:01 +0300 Subject: [PATCH 3/3] Add from, replyto options for activation --- core/components/login/processors/register.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/components/login/processors/register.php b/core/components/login/processors/register.php index 906a5b92..657a4e97 100644 --- a/core/components/login/processors/register.php +++ b/core/components/login/processors/register.php @@ -298,6 +298,10 @@ public function gatherActivationEmailProperties() { $emailProperties['tplAlt'] = $emailTplAlt; $emailProperties['tplType'] = $emailTplType; $emailProperties['password'] = $this->dictionary->get($this->controller->getProperty('passwordField','password')); + $emailProperties['emailFromName'] = $this->controller->getProperty('activationEmailFromName'); + $emailProperties['emailFrom'] = $this->controller->getProperty('activationEmailFrom'); + $emailProperties['emailReplyToName'] = $this->controller->getProperty('activationEmailReplyToName'); + $emailProperties['emailReplyTo'] = $this->controller->getProperty('activationEmailReplyTo'); $this->setCachePassword($pword); return $emailProperties; @@ -409,4 +413,4 @@ public function checkForRegisteredRedirect() { return false; } } -return 'LoginRegisterProcessor'; \ No newline at end of file +return 'LoginRegisterProcessor';