summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMelounek <petr@heralecky.cz>2012-06-29 08:43:47 +0200
committerMelounek <petr@heralecky.cz>2012-06-29 08:43:47 +0200
commit58dfc089bf5b0ca35c2ff244e5bfdff726f9adcd (patch)
tree10746fada189e9839406f6eb1a1fcd4f31496be2
parentffe7938b8d6dfdbdac8a34008dbbb15d31de6080 (diff)
added parameter for returned-path in Email::from()
-rw-r--r--system/libraries/Email.php17
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/email.rst7
3 files changed, 21 insertions, 4 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index dd5477e05..9270d5fca 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -188,7 +188,7 @@ class CI_Email {
* @param string
* @return object
*/
- public function from($from, $name = '')
+ public function from($from, $name = '', $return_path = '')
{
if (preg_match('/\<(.*)\>/', $from, $match))
{
@@ -198,6 +198,10 @@ class CI_Email {
if ($this->validate)
{
$this->validate_email($this->_str_to_array($from));
+ if($return_path)
+ {
+ $this->validate_email($this->_str_to_array($return_path));
+ }
}
// prepare the display name
@@ -216,7 +220,12 @@ class CI_Email {
}
$this->set_header('From', $name.' <'.$from.'>');
- $this->set_header('Return-Path', '<'.$from.'>');
+
+ if(!$return_path)
+ {
+ $return_path = $from;
+ }
+ $this->set_header('Return-Path', '<'.$return_path.'>');
return $this;
}
@@ -1385,7 +1394,7 @@ class CI_Email {
{
// most documentation of sendmail using the "-f" flag lacks a space after it, however
// we've encountered servers that seem to require it to be in place.
- return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$this->clean_email($this->_headers['From']));
+ return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$this->clean_email($this->_headers['Return-Path']));
}
}
@@ -1398,7 +1407,7 @@ class CI_Email {
*/
protected function _send_with_sendmail()
{
- $fp = @popen($this->mailpath.' -oi -f '.$this->clean_email($this->_headers['From']).' -t', 'w');
+ $fp = @popen($this->mailpath.' -oi -f '.$this->clean_email($this->_headers['From']).' -t'.' -r '.$this->clean_email($this->_headers['Return-Path']), 'w');
if ($fp === FALSE OR $fp === NULL)
{
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 28e2f94bb..4f5915de8 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -138,6 +138,7 @@ Release Date: Not Released
- CI_Loader::_ci_autoloader() is now a protected method.
- Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname).
- Added possibility to send attachment as buffer string in Email::attach() as $this->email->attach($buffer, $disposition, $newname, $mime).
+ - Added third parameter $return_path for method Email::from().
- :doc:`Cart library <libraries/cart>` changes include:
- It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites.
- Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe".
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index f99eb91df..8d2549d11 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -117,6 +117,13 @@ Sets the email address and name of the person sending the email::
$this->email->from('you@example.com', 'Your Name');
+::
+
+ $this->email->from('you@example.com', 'Your Name', 'returned_emails@example.com');
+
+Third parameter is redirect for undelivered emails (may not be configured with
+protocol 'smtp').
+
$this->email->reply_to()
-------------------------