squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Deliver_SendMail.class.php
Go to the documentation of this file.
1 <?php
2 
17 require_once(SM_PATH . 'class/deliver/Deliver.class.php');
18 
23 class Deliver_SendMail extends Deliver {
37  var $sendmail_args = '-i -t';
38 
46 
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  }
62 
74  function preWriteToStream(&$s) {
75  if ($s) {
76  $s = str_replace("\r\n", "\n", $s);
77  }
78  }
79 
91  $rfc822_header = $message->rfc822_header;
92  $from = $rfc822_header->from[0];
93  $envelopefrom = trim($from->mailbox.'@'.$from->host);
94  $envelopefrom = str_replace(array("\0","\n"),array('',''),$envelopefrom);
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");
99  return $stream;
100  }
101 
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;
123  }
124 
133  function getBcc() {
134  return true;
135  }
136 
150  function clean_crlf(&$s) {
151  $s = str_replace("\r\n", "\n", $s);
152  $s = str_replace("\r", "\n", $s);
153  $s2 = str_replace("\n", "\r\n", $s);
154  return strlen($s2);
155  }
156 
157 
158 }
$ret
$ret
Definition: webmail.php:172
Deliver_SendMail\preWriteToStream
preWriteToStream(&$s)
Definition: Deliver_SendMail.class.php:74
$sendmail_path
$sendmail_path
Definition: config_default.php:180
$from
$from
Definition: printer_friendly_bottom.php:60
$rfc822_header
$rfc822_header
Definition: compose.php:362
Deliver_SendMail\Deliver_SendMail
Deliver_SendMail($params=array())
Definition: Deliver_SendMail.class.php:54
Deliver_SendMail\$sendmail_command
$sendmail_command
Definition: Deliver_SendMail.class.php:45
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
$message
$message
Definition: download.php:54
Deliver
Definition: Deliver.class.php:29
Deliver_SendMail
Definition: Deliver_SendMail.class.php:23
Deliver_SendMail\clean_crlf
clean_crlf(&$s)
Definition: Deliver_SendMail.class.php:150
Deliver_SendMail\initStream
initStream($message, $sendmail_path)
Definition: Deliver_SendMail.class.php:90
Deliver_SendMail\getBcc
getBcc()
Definition: Deliver_SendMail.class.php:133
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
_
_($str)
Definition: gettext.php:160
Deliver_SendMail\finalizeStream
finalizeStream($stream)
Definition: Deliver_SendMail.class.php:111
$stream
$stream
Definition: configtest.php:429
Deliver_SendMail\$sendmail_args
$sendmail_args
Definition: Deliver_SendMail.class.php:37