/**
* Deliver.class.php
*
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains all the functions needed to send messages through
* a delivery backend.
*
- * $Id$
- *
+ * @version $Id$
* @author Marc Groot Koerkamp
* @package squirrelmail
*/
-
/**
* Deliver Class - called to actually deliver the message
*
* @param Message $message Message class to send
* @param resource $stream file handle to the SMTP stream
*
- * @returns integer $raw_length
+ * @return integer $raw_length
*/
function mail($message, $stream=false) {
$rfc822_header = $message->rfc822_header;
* as returned by mail fn
* @param string $boundary custom boundary to call, usually for subparts
*
- * @returns void
+ * @return void
*/
function writeBody($message, $stream, &$length_raw, $boundary='') {
// calculate boundary in case of multidimensional mime structures
* @param integer &$length length of the message part
* as returned by mail fn
*
- * @returns void
+ * @return void
*/
function writeBodyPart($message, $stream, &$length) {
if ($message->mime_header) {
*
* @param string &$s string to clean linefeeds on
*
- * @returns void
+ * @return void
*/
function clean_crlf(&$s) {
$s = str_replace("\r\n", "\n", $s);
*
* @param string &$s string to clean linefeeds on
*
- * @returns void
+ * @return void
*/
function strip_crlf(&$s) {
$s = str_replace("\r\n ", '', $s);
*
* @param string &$s string to operate on
*
- * @returns void
+ * @return void
*/
function preWriteToStream(&$s) {
}
* @param resource $stream SMTP output stream
* @param string $data string with data to send to the SMTP stream
*
- * @returns void
+ * @return void
*/
function writeToStream($stream, $data) {
fputs($stream, $data);
* @param string $pass password to log into the SMTP server with
* @param integer $length
*
- * @returns handle $stream file handle resource to SMTP stream
+ * @return handle $stream file handle resource to SMTP stream
*/
function initStream($message, $length=0, $host='', $port='', $user='', $pass='') {
return $stream;
* @param Message $message Message object to act on
* @param string $boundary mime boundary from fn MimeBoundary
*
- * @returns string $header properly formatted mime header
+ * @return string $header properly formatted mime header
*/
function prepareMIME_Header($message, $boundary) {
$mime_header = $message->mime_header;
* @param Rfc822Header $reply_rfc822_header
* @param integer &$raw_length length of the message
*
- * @returns
+ * @return string $header
*/
function prepareRFC822_Header($rfc822_header, $reply_rfc822_header, &$raw_length) {
- global $domain, $version, $username;
+ global $domain, $version, $username, $skip_SM_header;
/* if server var SERVER_NAME not available, use $domain */
if(!sqGetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER)) {
$date = date('D, j M Y H:i:s ', mktime()) . $this->timezone();
/* Create a message-id */
$message_id = '<' . $REMOTE_PORT . '.' . $REMOTE_ADDR . '.';
- $message_id .= time() . '.squirrel@' . $REMOTE_ADDR .'>';
+ $message_id .= time() . '.squirrel@' . $SERVER_NAME .'>';
/* Make an RFC822 Received: line */
if (isset($REMOTE_HOST)) {
$received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
$received_from .= " (proxying for $HTTP_X_FORWARDED_FOR)";
}
$header = array();
- $header[] = "Received: from $received_from" . $rn;
- $header[] = " (SquirrelMail authenticated user $username);" . $rn;
- $header[] = " by $SERVER_NAME with HTTP;" . $rn;
- $header[] = " $date" . $rn;
+ if ( !isset($skip_SM_header) || !$skip_SM_header )
+ {
+ $header[] = "Received: from $received_from" . $rn;
+ $header[] = " (SquirrelMail authenticated user $username);" . $rn;
+ $header[] = " by $SERVER_NAME with HTTP;" . $rn;
+ $header[] = " $date" . $rn;
+ }
/* Insert the rest of the header fields */
$header[] = 'Message-ID: '. $message_id . $rn;
if ($reply_rfc822_header->message_id) {
}
$header[] = "Date: $date" . $rn;
$header[] = 'Subject: '.encodeHeader($rfc822_header->subject) . $rn;
- $header[] = 'From: '. $rfc822_header->getAddr_s('from',',',true) . $rn;
- /* RFC2822 if from contains more then 1 address */
+ $header[] = 'From: '. $rfc822_header->getAddr_s('from',",$rn ",true) . $rn;
+
+ // folding address list [From|To|Cc|Bcc] happens by using ",$rn<space>" as delimiter
+ // Do not use foldLine for that.
+
+ // RFC2822 if from contains more then 1 address
if (count($rfc822_header->from) > 1) {
$header[] = 'Sender: '. $rfc822_header->getAddr_s('sender',',',true) . $rn;
}
if (count($rfc822_header->to)) {
- $header[] = 'To: '. $rfc822_header->getAddr_s('to',',',true) . $rn;
+ $header[] = 'To: '. $rfc822_header->getAddr_s('to',",$rn ",true) . $rn;
}
if (count($rfc822_header->cc)) {
- $header[] = 'Cc: '. $rfc822_header->getAddr_s('cc',',',true) . $rn;
+ $header[] = 'Cc: '. $rfc822_header->getAddr_s('cc',",$rn ",true) . $rn;
}
if (count($rfc822_header->reply_to)) {
$header[] = 'Reply-To: '. $rfc822_header->getAddr_s('reply_to',',',true) . $rn;
/* Sendmail should return true. Default = false */
$bcc = $this->getBcc();
if (count($rfc822_header->bcc)) {
- $s = 'Bcc: '. $rfc822_header->getAddr_s('bcc',',',true) . $rn;
+ $s = 'Bcc: '. $rfc822_header->getAddr_s('bcc',",$rn ",true) . $rn;
if (!$bcc) {
- $s = $this->foldLine($s, 78, str_pad('',4));
$raw_length += strlen($s);
} else {
$header[] = $s;
}
/* Identify SquirrelMail */
$header[] = 'User-Agent: SquirrelMail/' . $version . $rn;
- // Spamassassin complains about no X-Mailer in combination with X-Priority
- $header[] = 'X-Mailer: SquirrelMail/' . $version . $rn;
/* Do the MIME-stuff */
$header[] = 'MIME-Version: 1.0' . $rn;
$contenttype = 'Content-Type: '. $rfc822_header->content_type->type0 .'/'.
$header[] = 'Disposition-Notification-To: '.$dnt. $rn;
}
if ($rfc822_header->priority) {
- $prio = $rfc822_header->priority;
- $header[] = 'X-Priority: '. $prio. $rn;
- switch($prio)
+ switch($rfc822_header->priority)
{
- case 1: $header[] = 'Importance: High'. $rn; break;
- case 3: $header[] = 'Importance: Normal'. $rn; break;
- case 5: $header[] = 'Importance: Low'. $rn; break;
+ case 1:
+ $header[] = 'X-Priority: 1 (Highest)'.$rn;
+ $header[] = 'Importance: High'. $rn; break;
+ case 3:
+ $header[] = 'X-Priority: 3 (Normal)'.$rn;
+ $header[] = 'Importance: Normal'. $rn; break;
+ case 5:
+ $header[] = 'X-Priority: 5 (Lowest)'.$rn;
+ $header[] = 'Importance: Low'. $rn; break;
default: break;
}
}
}
$hdr_s .= $sLine;
break;
+ case 'To':
+ case 'Cc':
+ case 'Bcc':
+ case 'From':
+ $hdr_s .= $header[$i];
+ break;
default: $hdr_s .= $this->foldLine($header[$i], 78, str_pad('',4)); break;
}
}
* @param integer $length length to fold the line at
* @param string $pre prefix the line with...
*
- * @returns string $line folded line with trailing CRLF
+ * @return string $line folded line with trailing CRLF
*/
function foldLine($line, $length, $pre='') {
$line = substr($line,0, -2);
* This function will generate a random mime boundary base part
* for the message if the boundary has not already been set.
*
- * @returns string $mimeBoundaryString random mime boundary string
+ * @return string $mimeBoundaryString random mime boundary string
*/
function mimeBoundary () {
static $mimeBoundaryString;
/**
* function timezone - Time offset for correct timezone
*
- * @returns string $result with timezone and offset
+ * @return string $result with timezone and offset
*/
function timezone () {
global $invert_time;
*
* @param Rfc822Header $hdr message header to calculate from
*
- * @returns string $refer concatenated and trimmed Referer string
+ * @return string $refer concatenated and trimmed Referer string
*/
function calculate_references($hdr) {
$refer = $hdr->references;
return $refer;
}
}
-?>
\ No newline at end of file
+?>