Fixed bug #292 concerning ReturnPAth in htmlmail class. The fix has two different...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_htmlmail.php
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;}