return $array;
}
-
/* looks up aliases in the addressbook and expands them to
* the RFC 821 valid RCPT address. ie <user@example.com>
* Adds @$domain if it wasn't in the address book and if it
if ( isset($info['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 =
$languages[$squirrelmail_language]['XTRA_CODE']('encode', $remotefilename);
}
if (substr($filetype, 0, 5) == 'text/' ||
substr($filetype, 0, 8) == 'message/' ) {
$header .= $rn;
- if ($fp) {
- fputs ($fp, $header);
- }
+ if ($fp) {
+ fputs ($fp, $header);
+ }
$length += strlen($header);
+
if ($checkdot) {
$checkdot_begin=true;
} else {
$checkdot_begin=false;
}
+
while ($tmp = fgets($file, 4096)) {
$tmp = str_replace("\r\n", "\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) {
$tmp = '.' . $tmp;
}
$tmp = str_replace("\n.","\n..",$tmp);
}
- if ($rn == "\r\n"){
- $tmp = str_replace("\n", "\r\n", $tmp);
- }
$tmp_length = strlen($tmp);
- if ($tmp{$tmp_length-1} == "\n" && $checkdot) {
+ if ($tmp_length && $tmp{$tmp_length-1} == "\n" && $checkdot) {
$checkdot_begin = true;
} else {
$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) {
fputs($fp, $rn);
+ $length += strlen($rn);
}
}
+
+
} else {
$header .= "Content-Transfer-Encoding: base64"
. "$rn" . "$rn";
return (strlen($body) + strlen($postbody) + $attachmentlength);
}
+
/* Send mail using the sendmail command
*/
function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
$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");
$bodylength = writeBody($fp, $body, $session, "\n", true);
/* Send the message */
$headerlength = write822Header ($smtpConnection, $t, $c, $b,
$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 */
$tmp = fgets($smtpConnection, 1024);
$refer = "";
for ($i=1;$i<count($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]);
}
- else {
- $refer .= ' ' . trim($refs[0][$i]);
- }
-
+ else {
+ $refer .= ' ' . trim($refs[0][$i]);
+ }
}
}
$refer_a = explode(' ', $refer);
$refer = '';
foreach ($refer_a as $ref) {
$ref = trim($ref);
- if ($ref{0} == '<' && $ref{(strlen($ref)-1)} == '>') {
+ if ($ref && $ref{0} == '<' && $ref{(strlen($ref)-1)} == '>') {
$refer .= $ref . ' ';
}
}
if (isset($reply_id) && $reply_id) {
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
* message-id of the message we reply to is set (longer than "<>")
if ( $requestRecipt > 0) {
$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) {
$more_headers["Content-Type"] = "multipart/report; ".
"report-type=disposition-notification;";
}
-
+ $imap_body = $body;
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);
- $body = ereg_replace("\n", "\r\n", $body);
} 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);
}
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);
write822Header ($imap_stream, $t, $c, $b, $subject, $body, $more_headers,
$session);
if ($length) {
ClearAttachments($session);
}
-
return $length;
}