From 636f6f0705bfad855800df43e2e7fd5eda115e61 Mon Sep 17 00:00:00 2001 From: Huib Date: Sun, 26 Aug 2012 20:32:17 +0200 Subject: [PATCH] Added Envelope From to SMTP gateway --- .../lib/toolkit/email-gateways/email.smtp.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/symphony/lib/toolkit/email-gateways/email.smtp.php b/symphony/lib/toolkit/email-gateways/email.smtp.php index cc6befcd3c..4f1aa7ace0 100644 --- a/symphony/lib/toolkit/email-gateways/email.smtp.php +++ b/symphony/lib/toolkit/email-gateways/email.smtp.php @@ -24,6 +24,7 @@ protected $_auth = false; protected $_user; protected $_pass; + protected $_envelope_from; /** * Returns the name, used in the dropdown menu in the preferences pane. @@ -129,8 +130,8 @@ public function send(){ $this->_SMTP->setHeader($name, EmailHelper::fold($body)); } - // Send the email - $this->_SMTP->sendMail($this->_sender_email_address, $this->_recipients, $this->_subject, $this->_body); + // Send the email command. If the envelope from variable is set, use that for the MAIL command. This improves bounce handling. + $this->_SMTP->sendMail(is_null($this->_envelope_from)?$this->_sender_email_address:$this->_envelope_from, $this->_recipients, $this->_subject, $this->_body); if($this->_keepalive == false){ $this->closeConnection(); } @@ -240,6 +241,19 @@ public function setSecure($secure = null){ } } + /** + * Sets the envelope_from address. This is only available via the API, as it is an expert-only feature. + * + * @since 2.3.1 + * @return void + */ + public function setEnvelopeFrom($envelope_from = null){ + if(preg_match('%[\r\n]%', $envelope_from)){ + throw new EmailValidationException(__('The Envelope From Address can not contain carriage return or newlines.')); + } + $this->_envelope_from = $envelope_from; + } + /** * Builds the preferences pane, shown in the Symphony backend. * @@ -322,4 +336,4 @@ public function getPreferencesPane(){ return $group; } - } + } \ No newline at end of file