~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to class/deliver/Deliver_SendMail.class.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2006-08-11 13:53:20 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060811135320-a54q8uf2ncuwc5es
Tags: 2:1.4.8-1
* New upstream release
  - Includes security fix: variable overwriting in compose.php
    by logged-in user [CVE-2006-4019]
  - Does not ship SquirrelMail developer's documentation anymore.

* Remove duplicate content from README.locales.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * @author Marc Groot Koerkamp
9
9
 * @copyright © 1999-2006 The SquirrelMail Project Team
10
10
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11
 
 * @version $Id: Deliver_SendMail.class.php,v 1.11.2.8 2006/02/03 22:27:46 jervfors Exp $
 
11
 * @version $Id: Deliver_SendMail.class.php,v 1.11.2.9 2006/08/01 05:47:32 tokul Exp $
12
12
 * @package squirrelmail
13
13
 */
14
14
 
21
21
 * @package squirrelmail
22
22
 */
23
23
class Deliver_SendMail extends Deliver {
 
24
    /**
 
25
     * Extra sendmail arguments
 
26
     *
 
27
     * Parameter can be set in class constructor function.
 
28
     *
 
29
     * WARNING: Introduction of this parameter broke backwards compatibility 
 
30
     * with workarounds specific to qmail-inject.
 
31
     *
 
32
     * If parameter needs some security modifications, it should be set to 
 
33
     * private in PHP 5+ in order to prevent uncontrolled access.
 
34
     * @var string
 
35
     * @since 1.5.1 and 1.4.8
 
36
     */
 
37
    var $sendmail_args = '-i -t';
 
38
 
 
39
    /**
 
40
     * Stores used sendmail command
 
41
     * Private variable that is used to inform about used sendmail command.
 
42
     * @var string
 
43
     * @since 1.5.1 and 1.4.8
 
44
     */
 
45
    var $sendmail_command = '';
 
46
 
 
47
    /**
 
48
     * Constructor function
 
49
     * @param array configuration options. array key = option name, 
 
50
     * array value = option value.
 
51
     * @return void
 
52
     * @since 1.5.1 and 1.4.8
 
53
     */
 
54
    function Deliver_SendMail($params=array()) {
 
55
        if (!empty($params) && is_array($params)) {
 
56
            // set extra sendmail arguments
 
57
            if (isset($params['sendmail_args'])) {
 
58
                $this->sendmail_args = $params['sendmail_args'];
 
59
            }
 
60
        }
 
61
    }
24
62
 
25
63
   /**
26
64
    * function preWriteToStream
54
92
        $from = $rfc822_header->from[0];
55
93
        $envelopefrom = trim($from->mailbox.'@'.$from->host);
56
94
        $envelopefrom = str_replace(array("\0","\n"),array('',''),$envelopefrom);
57
 
        if (strstr($sendmail_path, "qmail-inject")) {
58
 
            $stream = popen (escapeshellcmd("$sendmail_path -f$envelopefrom"), "w");
59
 
        } else {
60
 
            $stream = popen (escapeshellcmd("$sendmail_path -i -t -f$envelopefrom"), "w");
61
 
        }
 
95
        // save executed command for future reference
 
96
        $this->sendmail_command = "$sendmail_path $this->sendmail_args -f$envelopefrom";
 
97
        // open process handle for writing
 
98
        $stream = popen(escapeshellcmd($this->sendmail_command), "w");
62
99
        return $stream;
63
100
    }
64
101
 
72
109
    * @access public
73
110
    */
74
111
    function finalizeStream($stream) {
75
 
        pclose($stream);
76
 
        return true;
 
112
        $ret = true;
 
113
        $status = pclose($stream);
 
114
        // check pclose() status.
 
115
        if ($status!=0) {
 
116
            $ret = false;
 
117
            $this->dlv_msg=_("Email delivery error");
 
118
            $this->dlv_ret_nr=$status;
 
119
            // we can get better error messsage only if we switch to php 4.3+ and proc_open().
 
120
            $this->dlv_server_msg=sprintf(_("Can't execute command '%s'."),$this->sendmail_command);
 
121
        }
 
122
        return $ret;
77
123
    }
78
124
 
79
125
   /**
85
131
    * @access private
86
132
    */
87
133
    function getBcc() {
88
 
       return true;
 
134
        return true;
89
135
    }
90
136
 
91
137
   /**