Fixed bug #292 concerning ReturnPAth in htmlmail class. The fix has two different...
authorJan-Erik Revsbech <jer@moccompany.com>
Thu, 9 Sep 2004 21:30:36 +0000 (21:30 +0000)
committerJan-Erik Revsbech <jer@moccompany.com>
Thu, 9 Sep 2004 21:30:36 +0000 (21:30 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@458 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_htmlmail.php

index 18ed8d8..1335cbc 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2004-09-00  Jan-Erik Revsbech    <jer@moccompany.com>
+       * Fixed bug #292 concerning Return path in class.t3lib_mailer.php. The fix has a seperate solution for windows and Unix. The unix fix does however not work with safe_mode enabled. Do not know how to overcome this. Perhaps an environment variable for sendmail can be specified? The fix for windows works OK with safe_mode on since, it does not rely on passing parameter directly to the mailer tranport agent (Sendmail or postfix), but instead sets the php variable sendmail_from, which has no effect on Unix systemt.
+
 2004-09-02  Kasper Skårhøj,,,  <kasper@typo3.com>
 
        * Fixed a few basic PHP5 problems (aiming at PHP5 support in 3.7.0)
index 366aadf..78cff95 100755 (executable)
@@ -604,16 +604,40 @@ class t3lib_htmlmail {
                        // Requires the recipient, message and headers to be set.
 #debug(array($this->recipient,$this->subject,$this->message,$this->headers));
                if (trim($this->recipient) && trim($this->message))     {       //  && trim($this->headers)
-                       mail(   $this->recipient,
+                       $returnPath = (strlen($this->returnPath)>0)?"-f".$this->returnPath:'';
+                       //On windows the -f flag is not used (specific for sendmail and postfix), but instead the php.ini parameter sendmail_from is used.
+                        if($this->returnPath) {
+                         ini_set(sendmail_from, $this->returnPath);
+                       }
+                       //If safe mode is on, the fifth parameter to mail is not allowed, so the fix wont work on unix with safe_mode=On
+                       if(!ini_get('safe_mode')) {
+                               mail(   $this->recipient,
+                                       $this->subject,
+                                       $this->message,
+                                       $this->headers,
+                                       $returnPath);
+                       }
+                       else {
+                               mail(   $this->recipient,
                                        $this->subject,
                                        $this->message,
-                                       $this->headers  );
+                                       $this->headers);
+                       }
                                // Sending copy:
                        if ($this->recipient_copy)      {
+                         if(!ini_get('safe_mode')) {
                                mail(   $this->recipient_copy,
                                                $this->subject,
                                                $this->message,
+                                               $this->headers,
+                                               $returnPath);
+                         }
+                         else {
+                           mail(       $this->recipient_copy,
+                                               $this->subject,
+                                               $this->message,
                                                $this->headers  );
+                         }
                        }
                                // Auto response
                        if ($this->auto_respond_msg)    {
@@ -622,7 +646,11 @@ class t3lib_htmlmail {
                                mail(   $this->from_email,
                                                $theParts[0],
                                                $theParts[1],
-                                               "From: ".$this->recipient       );
+                                               "From: ".$this->recipient,
+                                               $returnPath);
+                       }
+                       if($this->returnPath) {
+                         ini_restore(sendmail_from);
                        }
                        return true;
                } else {return false;}