3 * Deliver_SendMail.class.php
5 * Copyright (c) 1999-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * Delivery backend for the Deliver class.
11 * @package squirrelmail
14 /** This of course depends upon Deliver */
15 require_once(SM_PATH
. 'class/deliver/Deliver.class.php');
18 * Delivers messages using the sendmail binary
19 * @package squirrelmail
21 class Deliver_SendMail
extends Deliver
{
23 function preWriteToStream(&$s) {
25 $s = str_replace("\r\n", "\n", $s);
29 function initStream($message, $sendmail_path) {
30 $rfc822_header = $message->rfc822_header
;
31 $from = $rfc822_header->from
[0];
32 $envelopefrom = trim($from->mailbox
.'@'.$from->host
);
33 $envelopefrom = str_replace(array("\0","\n"),array('',''),$envelopefrom);
34 if (strstr($sendmail_path, "qmail-inject")) {
35 $stream = popen (escapeshellcmd("$sendmail_path -i -f$envelopefrom"), "w");
37 $stream = popen (escapeshellcmd("$sendmail_path -i -t -f$envelopefrom"), "w");
42 function finalizeStream($stream) {
54 * Cleans each line to only end in a LF
55 * Returns the length of the line including a CR,
56 * so that length is correct when the message is saved to imap
57 * Implemented to fix sendmail->postfix rejection of messages with attachments because of stray LF's
59 * @param string $s string to strip of CR's
60 * @return integer length of string including a CR for each LF
62 function clean_crlf(&$s) {
63 $s = str_replace("\r\n", "\n", $s);
64 $s = str_replace("\r", "\n", $s);
65 $s2 = str_replace("\n", "\r\n", $s);