Happy New Year
[squirrelmail.git] / class / deliver / Deliver_SendMail.class.php
index de5863875b21ae1686aae2cba9604a1c8139d5f9..4c46ab4529f9ceea5996821cac5544e127410a86 100644 (file)
@@ -6,7 +6,7 @@
  * Delivery backend for the Deliver class.
  *
  * @author Marc Groot Koerkamp
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright 1999-2020 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -47,13 +47,13 @@ class Deliver_SendMail extends Deliver {
     var $sendmail_command = '';
 
     /**
-     * Constructor function
+     * Constructor (PHP5 style, required in some future version of PHP)
      * @param array configuration options. array key = option name, 
      * array value = option value.
      * @return void
      * @since 1.5.1
      */
-    function Deliver_SendMail($params=array()) {
+    function __construct($params=array()) {
         if (!empty($params) && is_array($params)) {
             // set extra sendmail arguments
             if (isset($params['sendmail_args'])) {
@@ -62,6 +62,17 @@ class Deliver_SendMail extends Deliver {
         }
     }
 
+    /**
+     * Constructor (PHP4 style, kept for compatibility reasons)
+     * @param array configuration options. array key = option name, 
+     * array value = option value.
+     * @return void
+     * @since 1.5.1
+     */
+    function Deliver_SendMail($params=array()) {
+        self::__construct($params);
+    }
+
    /**
     * function preWriteToStream
     *
@@ -86,18 +97,19 @@ class Deliver_SendMail extends Deliver {
     *
     * @param Message $message Message object containing the from address
     * @param string $sendmail_path Location of sendmail binary
+    * @param mixed $ignore_x Eight extra arguments that the parent class
+    *                        requires which are not used here
     * @return resource
     * @access public
     */
-    function initStream($message, $sendmail_path) {
+    function initStream($message, $sendmail_path, $ignore_1=0, $ignore_2='', $ignore_3='', $ignore_4='', $ignore_5='', $ignore_6=false, $ignore_7='', $ignore_8=array()) {
         $rfc822_header = $message->rfc822_header;
         $from = $rfc822_header->from[0];
         $envelopefrom = trim($from->mailbox.'@'.$from->host);
-        $envelopefrom = str_replace(array("\0","\n"),array('',''),$envelopefrom);
         // save executed command for future reference
-        $this->sendmail_command = "$sendmail_path $this->sendmail_args -f$envelopefrom";
+        $this->sendmail_command = escapeshellcmd("$sendmail_path $this->sendmail_args -f") . escapeshellarg($envelopefrom);
         // open process handle for writing
-        $stream = popen (escapeshellcmd($this->sendmail_command), "w");
+        $stream = popen($this->sendmail_command, "w");
         return $stream;
     }
 
@@ -156,4 +168,3 @@ class Deliver_SendMail extends Deliver {
 
 
 }
-?>
\ No newline at end of file