Skip to content

Commit

Permalink
Added Envelope From to SMTP gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
creativedutchmen committed Aug 26, 2012
1 parent 18db0f4 commit 636f6f0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions symphony/lib/toolkit/email-gateways/email.smtp.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -322,4 +336,4 @@ public function getPreferencesPane(){

return $group;
}
}
}

0 comments on commit 636f6f0

Please sign in to comment.