|
@@ -77,7 +77,6 @@ function expandAddrs ($array) {
|
|
return $array;
|
|
return $array;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/* looks up aliases in the addressbook and expands them to
|
|
/* looks up aliases in the addressbook and expands them to
|
|
* the RFC 821 valid RCPT address. ie <user@example.com>
|
|
* the RFC 821 valid RCPT address. ie <user@example.com>
|
|
* Adds @$domain if it wasn't in the address book and if it
|
|
* Adds @$domain if it wasn't in the address book and if it
|
|
@@ -130,7 +129,8 @@ function attachFiles ($fp, $session, $rn="\r\n", $checkdot = false) {
|
|
if ( isset($info['remotefilename'])
|
|
if ( isset($info['remotefilename'])
|
|
&& $info['remotefilename'] != '') {
|
|
&& $info['remotefilename'] != '') {
|
|
$remotefilename = $info['remotefilename'];
|
|
$remotefilename = $info['remotefilename'];
|
|
- if (function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
|
|
|
|
|
|
+ if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
|
|
|
|
+ function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
|
|
$remotefilename =
|
|
$remotefilename =
|
|
$languages[$squirrelmail_language]['XTRA_CODE']('encode', $remotefilename);
|
|
$languages[$squirrelmail_language]['XTRA_CODE']('encode', $remotefilename);
|
|
}
|
|
}
|
|
@@ -153,22 +153,23 @@ function attachFiles ($fp, $session, $rn="\r\n", $checkdot = false) {
|
|
if (substr($filetype, 0, 5) == 'text/' ||
|
|
if (substr($filetype, 0, 5) == 'text/' ||
|
|
substr($filetype, 0, 8) == 'message/' ) {
|
|
substr($filetype, 0, 8) == 'message/' ) {
|
|
$header .= $rn;
|
|
$header .= $rn;
|
|
- if ($fp) {
|
|
|
|
- fputs ($fp, $header);
|
|
|
|
- }
|
|
|
|
|
|
+ if ($fp) {
|
|
|
|
+ fputs ($fp, $header);
|
|
|
|
+ }
|
|
$length += strlen($header);
|
|
$length += strlen($header);
|
|
|
|
+
|
|
if ($checkdot) {
|
|
if ($checkdot) {
|
|
$checkdot_begin=true;
|
|
$checkdot_begin=true;
|
|
} else {
|
|
} else {
|
|
$checkdot_begin=false;
|
|
$checkdot_begin=false;
|
|
}
|
|
}
|
|
|
|
+
|
|
while ($tmp = fgets($file, 4096)) {
|
|
while ($tmp = fgets($file, 4096)) {
|
|
$tmp = str_replace("\r\n", "\n", $tmp);
|
|
$tmp = str_replace("\r\n", "\n", $tmp);
|
|
$tmp = str_replace("\r", "\n", $tmp);
|
|
$tmp = str_replace("\r", "\n", $tmp);
|
|
- /* In order to remove the problem of users not able to create
|
|
|
|
- * messages with "." on a blank line, RFC821 has made provision
|
|
|
|
- * in section 4.5.2 (Transparency).
|
|
|
|
- */
|
|
|
|
|
|
+ if ($rn == "\r\n"){
|
|
|
|
+ $tmp = str_replace("\n", "\r\n", $tmp);
|
|
|
|
+ }
|
|
if ($tmp{0} == '.' && $checkdot_begin) {
|
|
if ($tmp{0} == '.' && $checkdot_begin) {
|
|
$tmp = '.' . $tmp;
|
|
$tmp = '.' . $tmp;
|
|
}
|
|
}
|
|
@@ -176,26 +177,27 @@ function attachFiles ($fp, $session, $rn="\r\n", $checkdot = false) {
|
|
$tmp = str_replace("\n.","\n..",$tmp);
|
|
$tmp = str_replace("\n.","\n..",$tmp);
|
|
}
|
|
}
|
|
|
|
|
|
- if ($rn == "\r\n"){
|
|
|
|
- $tmp = str_replace("\n", "\r\n", $tmp);
|
|
|
|
- }
|
|
|
|
$tmp_length = strlen($tmp);
|
|
$tmp_length = strlen($tmp);
|
|
- if ($tmp{$tmp_length-1} == "\n" && $checkdot) {
|
|
|
|
|
|
+ if ($tmp_length && $tmp{$tmp_length-1} == "\n" && $checkdot) {
|
|
$checkdot_begin = true;
|
|
$checkdot_begin = true;
|
|
} else {
|
|
} else {
|
|
$checkdot_begin = false;
|
|
$checkdot_begin = false;
|
|
}
|
|
}
|
|
- if ($fp) {
|
|
|
|
- fputs($fp, $tmp);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if ($fp) {
|
|
|
|
+ fputs($fp, $tmp);
|
|
}
|
|
}
|
|
- $length += strlen($tmp_length);
|
|
|
|
|
|
+ $length += $tmp_length;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (substr($tmp, strlen($tmp) - strlen($rn), strlen($rn)) != $rn) {
|
|
|
|
|
|
+ if (substr($tmp, $tmp_length - strlen($rn), strlen($rn)) != $rn) {
|
|
if ($fp) {
|
|
if ($fp) {
|
|
fputs($fp, $rn);
|
|
fputs($fp, $rn);
|
|
|
|
+ $length += strlen($rn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
$header .= "Content-Transfer-Encoding: base64"
|
|
$header .= "Content-Transfer-Encoding: base64"
|
|
. "$rn" . "$rn";
|
|
. "$rn" . "$rn";
|
|
@@ -492,6 +494,7 @@ function writeBody ($fp, $passedBody, $session, $rn="\r\n", $checkdot = false) {
|
|
return (strlen($body) + strlen($postbody) + $attachmentlength);
|
|
return (strlen($body) + strlen($postbody) + $attachmentlength);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/* Send mail using the sendmail command
|
|
/* Send mail using the sendmail command
|
|
*/
|
|
*/
|
|
function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
|
|
function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
|
|
@@ -516,7 +519,7 @@ function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
|
|
$fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
|
|
$fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
|
|
}
|
|
}
|
|
|
|
|
|
- $headerlength = write822Header ($fp, $t, $c, $b, $subject, $body,
|
|
|
|
|
|
+ $headerlength = write822Header ($fp, $t, $c, $b, $subject, $body,
|
|
$more_headers, $session, "\n");
|
|
$more_headers, $session, "\n");
|
|
$bodylength = writeBody($fp, $body, $session, "\n", true);
|
|
$bodylength = writeBody($fp, $body, $session, "\n", true);
|
|
|
|
|
|
@@ -675,7 +678,7 @@ function sendSMTP($t, $c, $b, $subject, $body, $more_headers, $session) {
|
|
/* Send the message */
|
|
/* Send the message */
|
|
$headerlength = write822Header ($smtpConnection, $t, $c, $b,
|
|
$headerlength = write822Header ($smtpConnection, $t, $c, $b,
|
|
$subject, $body, $more_headers, $session);
|
|
$subject, $body, $more_headers, $session);
|
|
- $bodylength = writeBody($smtpConnection, $body, $session, "\r\n", true);
|
|
|
|
|
|
+ $bodylength = writeBody($smtpConnection, $body, $session,"\r\n", true);
|
|
|
|
|
|
fputs($smtpConnection, ".\r\n"); /* end the DATA part */
|
|
fputs($smtpConnection, ".\r\n"); /* end the DATA part */
|
|
$tmp = fgets($smtpConnection, 1024);
|
|
$tmp = fgets($smtpConnection, 1024);
|
|
@@ -807,20 +810,19 @@ function calculate_references($refs, $inreplyto, $old_reply_to) {
|
|
$refer = "";
|
|
$refer = "";
|
|
for ($i=1;$i<count($refs[0]);$i++) {
|
|
for ($i=1;$i<count($refs[0]);$i++) {
|
|
if (!empty($refs[0][$i])) {
|
|
if (!empty($refs[0][$i])) {
|
|
- if (preg_match("/^References:(.+)$/UA", $refs[0][$i], $regs)) {
|
|
|
|
|
|
+ if (preg_match("/^References:(.+)$/UAi", $refs[0][$i], $regs)) {
|
|
$refer = trim($regs[1]);
|
|
$refer = trim($regs[1]);
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- $refer .= ' ' . trim($refs[0][$i]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ else {
|
|
|
|
+ $refer .= ' ' . trim($refs[0][$i]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$refer_a = explode(' ', $refer);
|
|
$refer_a = explode(' ', $refer);
|
|
$refer = '';
|
|
$refer = '';
|
|
foreach ($refer_a as $ref) {
|
|
foreach ($refer_a as $ref) {
|
|
$ref = trim($ref);
|
|
$ref = trim($ref);
|
|
- if ($ref{0} == '<' && $ref{(strlen($ref)-1)} == '>') {
|
|
|
|
|
|
+ if ($ref && $ref{0} == '<' && $ref{(strlen($ref)-1)} == '>') {
|
|
$refer .= $ref . ' ';
|
|
$refer .= $ref . ' ';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -856,7 +858,7 @@ function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
|
|
|
|
|
|
if (isset($reply_id) && $reply_id) {
|
|
if (isset($reply_id) && $reply_id) {
|
|
sqimap_mailbox_select ($imap_stream, $mailbox);
|
|
sqimap_mailbox_select ($imap_stream, $mailbox);
|
|
- sqimap_messages_flag ($imap_stream, $reply_id, $reply_id, 'Answered', false);
|
|
|
|
|
|
+ sqimap_messages_flag ($imap_stream, $reply_id, $reply_id, 'Answered', true);
|
|
|
|
|
|
/* Insert In-Reply-To and References headers if the
|
|
/* Insert In-Reply-To and References headers if the
|
|
* message-id of the message we reply to is set (longer than "<>")
|
|
* message-id of the message we reply to is set (longer than "<>")
|
|
@@ -903,53 +905,40 @@ function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
|
|
if ( $requestRecipt > 0) {
|
|
if ( $requestRecipt > 0) {
|
|
$more_headers = array_merge($more_headers, createReceiptHeaders($requestRecipt));
|
|
$more_headers = array_merge($more_headers, createReceiptHeaders($requestRecipt));
|
|
}
|
|
}
|
|
-
|
|
|
|
- /* this is to catch all plain \n instances and
|
|
|
|
- * replace them with \r\n. All newlines were converted
|
|
|
|
- * into just \n inside the compose.php file.
|
|
|
|
- * But only if delimiter is, in fact, \r\n.
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
if ($MDN) {
|
|
if ($MDN) {
|
|
$more_headers["Content-Type"] = "multipart/report; ".
|
|
$more_headers["Content-Type"] = "multipart/report; ".
|
|
"report-type=disposition-notification;";
|
|
"report-type=disposition-notification;";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $imap_body = $body;
|
|
if ($useSendmail) {
|
|
if ($useSendmail) {
|
|
- /* In order to remove the problem of users not able to create
|
|
|
|
- * messages with "." on a blank line, RFC821 has made provision
|
|
|
|
- * in section 4.5.2 (Transparency).
|
|
|
|
|
|
+ /* In order to remove the problem of users not able to create
|
|
|
|
+ * messages with "." on a blank line, RFC821 has made provision
|
|
|
|
+ * in section 4.5.2 (Transparency).
|
|
*/
|
|
*/
|
|
- $body_sendmail = $body;
|
|
|
|
- if (($body_sendmail{0} == '.')) {
|
|
|
|
- $body_sendmail = '.' . $body_sendmail;
|
|
|
|
|
|
+ if (($body && $body{0} == '.')) {
|
|
|
|
+ $body = '.' . $body;
|
|
}
|
|
}
|
|
- $body_sendmail = str_replace("\n.","\n..",$body_sendmail);
|
|
|
|
-
|
|
|
|
- $length = sendSendmail($t, $c, $b, $subject, $body_sendmail, $more_headers,
|
|
|
|
|
|
+ $body = str_replace("\n.","\n..",$body);
|
|
|
|
+ $length = sendSendmail($t, $c, $b, $subject, $body, $more_headers,
|
|
$session);
|
|
$session);
|
|
- $body = ereg_replace("\n", "\r\n", $body);
|
|
|
|
} else {
|
|
} else {
|
|
- $body = ereg_replace("\n", "\r\n", $body);
|
|
|
|
- /* In order to remove the problem of users not able to create
|
|
|
|
- * messages with "." on a blank line, RFC821 has made provision
|
|
|
|
- * in section 4.5.2 (Transparency).
|
|
|
|
- */
|
|
|
|
- $body_smtp = $body;
|
|
|
|
- if (($body_smtp{0} == '.')) {
|
|
|
|
- $body_smtp = '.' . $body_smtp;
|
|
|
|
- }
|
|
|
|
- $body_smtp = str_replace("\n.","\n..",$body_smtp);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $length = sendSMTP($t, $c, $b, $subject, $body_smtp, $more_headers,
|
|
|
|
|
|
+ /* In order to remove the problem of users not able to create
|
|
|
|
+ * messages with "." on a blank line, RFC821 has made provision
|
|
|
|
+ * in section 4.5.2 (Transparency).
|
|
|
|
+ */
|
|
|
|
+ if (($body && $body{0} == '.')) {
|
|
|
|
+ $body = '.' . $body;
|
|
|
|
+ }
|
|
|
|
+ $body = str_replace("\n.","\n..",$body);
|
|
|
|
+ $length = sendSMTP($t, $c, $b, $subject, $body, $more_headers,
|
|
$session);
|
|
$session);
|
|
}
|
|
}
|
|
if (sqimap_mailbox_exists ($imap_stream, $sent_folder)) {
|
|
if (sqimap_mailbox_exists ($imap_stream, $sent_folder)) {
|
|
- $headerlength = write822Header (false, $t, $c, $b, $subject, $more_headers, $session, "\r\n");
|
|
|
|
- $bodylength = writeBody(false, $body, $session, "\r\n");
|
|
|
|
- $length = $headerlength + $bodylength;
|
|
|
|
-
|
|
|
|
|
|
+ $body = $imap_body;
|
|
|
|
+ $body = ereg_replace("\n", "\r\n", $body);
|
|
|
|
+ $headerlength = write822Header (false, $t, $c, $b, $subject, $body, $more_headers, $session, "\r\n");
|
|
|
|
+ $bodylength = writeBody(false, $body, $session, "\r\n");
|
|
|
|
+ $length = $headerlength + $bodylength;
|
|
sqimap_append ($imap_stream, $sent_folder, $length);
|
|
sqimap_append ($imap_stream, $sent_folder, $length);
|
|
write822Header ($imap_stream, $t, $c, $b, $subject, $body, $more_headers,
|
|
write822Header ($imap_stream, $t, $c, $b, $subject, $body, $more_headers,
|
|
$session);
|
|
$session);
|
|
@@ -963,7 +952,6 @@ function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
|
|
if ($length) {
|
|
if ($length) {
|
|
ClearAttachments($session);
|
|
ClearAttachments($session);
|
|
}
|
|
}
|
|
-
|
|
|
|
return $length;
|
|
return $length;
|
|
}
|
|
}
|
|
|
|
|