6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This contains all the functions needed to send messages through
10 * an smtp server or sendmail.
15 require_once('../functions/addressbook.php');
16 require_once('../functions/plugin.php');
17 require_once('../functions/prefs.php');
19 global $username, $popuser, $domain;
21 /* This should most probably go to some initialization... */
22 if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
23 $popuser = $usernamedata[1];
24 $domain = $usernamedata[2];
29 /* We need domain for smtp */
31 $domain = getenv('HOSTNAME');
34 /* Returns true only if this message is multipart */
35 function isMultipart ($session) {
38 foreach ($attachments as $info) {
39 if ($info['session'] == $session) {
46 /* looks up aliases in the addressbook and expands them to
49 * Adds @$domain if it wasn't in the address book and if it
50 * doesn't have an @ symbol in it
52 function expandAddrs ($array) {
55 /* don't show errors -- kinda critical that we don't see
56 * them here since the redirect won't work if we do show them
58 $abook = addressbook_init(false, true);
59 for ($i=0; $i < count($array); $i++
) {
60 $result = $abook->lookup($array[$i]);
62 if (isset($result['email'])) {
63 if (isset($result['name'])) {
64 $ret = '"'.$result['name'].'" ';
66 $ret .= '<'.$result['email'].'>';
71 if (strpos($array[$i], '@') === false) {
72 $array[$i] .= '@' . $domain;
74 $array[$i] = '<' . $array[$i] . '>';
81 /* looks up aliases in the addressbook and expands them to
82 * the RFC 821 valid RCPT address. ie <user@example.com>
83 * Adds @$domain if it wasn't in the address book and if it
84 * doesn't have an @ symbol in it
86 function expandRcptAddrs ($array) {
89 /* don't show errors -- kinda critical that we don't see
90 * them here since the redirect won't work if we do show them
92 $abook = addressbook_init(false, true);
93 for ($i=0; $i < count($array); $i++
) {
94 $result = $abook->lookup($array[$i]);
96 if (isset($result['email'])) {
97 $ret = '<'.$result['email'].'>';
101 if (strpos($array[$i], '@') === false) {
102 $array[$i] .= '@' . $domain;
104 $array[$i] = '<' . $array[$i] . '>';
111 /* Attach the files that are due to be attached
113 function attachFiles ($fp, $session, $rn="\r\n") {
114 global $attachments, $attachment_dir, $username;
118 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
119 if (isMultipart($session)) {
120 foreach ($attachments as $info) {
121 if ($info['session'] == $session) {
122 if (isset($info['type'])) {
123 $filetype = $info['type'];
126 $filetype = 'application/octet-stream';
129 $header = '--' . mimeBoundary() . "$rn";
130 if ( isset($info['remotefilename'])
131 && $info['remotefilename'] != '') {
132 $header .= "Content-Type: $filetype; name=\"" .
133 $info['remotefilename'] . "\"$rn";
134 $header .= "Content-Disposition: attachment; filename=\""
135 . $info['remotefilename'] . "\"$rn";
137 $header .= "Content-Type: $filetype$rn";
141 /* Use 'rb' for NT systems -- read binary
142 * Unix doesn't care -- everything's binary! :-)
145 $filename = $hashed_attachment_dir . '/'
146 . $info['localfilename'];
147 $file = fopen ($filename, 'rb');
148 if (substr($filetype, 0, 5) == 'text/' ||
149 substr($filetype, 0, 8) == 'message/' ) {
151 fputs ($fp, $header);
152 $length +
= strlen($header);
153 while ($tmp = fgets($file, 4096)) {
154 $tmp = str_replace("\r\n", "\n", $tmp);
155 $tmp = str_replace("\r", "\n", $tmp);
157 $tmp = str_replace("\n", "\r\n", $tmp);
160 * Check if the last line has newline ($rn) in it
161 * and append if it doesn't.
163 if (feof($fp) && !strstr($tmp, "$rn")){
167 $length +
= strlen($tmp);
170 $header .= "Content-Transfer-Encoding: base64"
172 fputs ($fp, $header);
173 $length +
= strlen($header);
174 while ($tmp = fread($file, 570)) {
175 $encoded = chunk_split(base64_encode($tmp));
176 $length +
= strlen($encoded);
177 fputs ($fp, $encoded);
187 /* Delete files that are uploaded for attaching
189 function deleteAttachments($session) {
190 global $username, $attachments, $attachment_dir;
191 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
193 $rem_attachments = array();
194 foreach ($attachments as $info) {
195 if ($info['session'] == $session) {
196 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
197 if (file_exists($attached_file)) {
198 unlink($attached_file);
201 $rem_attachments[] = $info;
204 $attachments = $rem_attachments;
207 /* Return a nice MIME-boundary
209 function mimeBoundary () {
210 static $mimeBoundaryString;
212 if ( !isset( $mimeBoundaryString ) ||
213 $mimeBoundaryString == '') {
214 $mimeBoundaryString = '----=_' . date( 'YmdHis' ) . '_' .
215 mt_rand( 10000, 99999 );
218 return $mimeBoundaryString;
221 /* Time offset for correct timezone */
222 function timezone () {
225 $diff_second = date('Z');
227 $diff_second = - $diff_second;
229 if ($diff_second > 0) {
236 $diff_second = abs($diff_second);
238 $diff_hour = floor ($diff_second / 3600);
239 $diff_minute = floor (($diff_second-3600*$diff_hour) / 60);
241 $zonename = '('.strftime('%Z').')';
242 $result = sprintf ("%s%02d%02d %s", $sign, $diff_hour, $diff_minute,
247 /* Print all the needed RFC822 headers */
248 function write822Header ($fp, $t, $c, $b, $subject, $more_headers, $session, $rn="\r\n") {
249 global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
250 global $data_dir, $username, $popuser, $domain, $version, $useSendmail;
251 global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR;
252 global $REMOTE_HOST, $identity;
254 /* Storing the header to make sure the header is the same
255 * everytime the header is printed.
257 static $header, $headerlength;
260 $to = expandAddrs(parseAddrs($t));
261 $cc = expandAddrs(parseAddrs($c));
262 $bcc = expandAddrs(parseAddrs($b));
263 if (isset($identity) && $identity != 'default') {
264 $reply_to = getPref($data_dir, $username, 'reply_to' . $identity);
265 $from = getPref($data_dir, $username, 'full_name' . $identity);
266 $from_addr = getFrom();
268 $reply_to = getPref($data_dir, $username, 'reply_to');
269 $from = getPref($data_dir, $username, 'full_name');
270 $from_addr = getFrom();
273 $to_list = getLineOfAddrs($to);
274 $cc_list = getLineOfAddrs($cc);
275 $bcc_list = getLineOfAddrs($bcc);
277 /* Encoding 8-bit characters and making from line */
278 $subject = encodeHeader($subject);
280 $from = "<$from_addr>";
283 $from = '"' . encodeHeader($from) . "\" <$from_addr>";
286 /* This creates an RFC 822 date */
287 $date = date("D, j M Y H:i:s ", mktime()) . timezone();
289 /* Create a message-id */
290 $message_id = '<' . $REMOTE_PORT . '.' . $REMOTE_ADDR . '.';
291 $message_id .= time() . '.squirrel@' . $SERVER_NAME .'>';
293 /* Make an RFC822 Received: line */
294 if (isset($REMOTE_HOST)) {
295 $received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
298 $received_from = $REMOTE_ADDR;
301 if (isset($HTTP_VIA) ||
isset ($HTTP_X_FORWARDED_FOR)) {
302 if ($HTTP_X_FORWARDED_FOR == '') {
303 $HTTP_X_FORWARDED_FOR = 'unknown';
305 $received_from .= " (proxying for $HTTP_X_FORWARDED_FOR)";
308 $header = "Received: from $received_from" . $rn;
309 $header .= " (SquirrelMail authenticated user $username)" . $rn;
310 $header .= " by $SERVER_NAME with HTTP;" . $rn;
311 $header .= " $date" . $rn;
313 /* Insert the rest of the header fields */
314 $header .= "Message-ID: $message_id" . $rn;
315 $header .= "Date: $date" . $rn;
316 $header .= "Subject: $subject" . $rn;
317 $header .= "From: $from" . $rn;
318 $header .= "To: $to_list" . $rn; // Who it's TO
320 if (isset($more_headers["Content-Type"])) {
321 $contentType = $more_headers["Content-Type"];
322 unset($more_headers["Content-Type"]);
325 if (isMultipart($session)) {
326 $contentType = "multipart/mixed;";
329 if ($default_charset != '') {
330 $contentType = 'text/plain; charset='.$default_charset;
333 $contentType = 'text/plain;';
338 /* Insert headers from the $more_headers array */
339 if(is_array($more_headers)) {
340 reset($more_headers);
341 while(list($h_name, $h_val) = each($more_headers)) {
342 if ($h_name == 'References') {
343 $h_val = str_replace(' ', "$rn ", $h_val);
345 $header .= sprintf("%s: %s%s", $h_name, $h_val, $rn);
350 $header .= "Cc: $cc_list" . $rn; // Who the CCs are
353 if ($reply_to != '') {
354 $header .= "Reply-To: $reply_to" . $rn;
359 // BCCs is removed from header by sendmail
360 $header .= "Bcc: $bcc_list" . $rn;
364 /* Identify SquirrelMail */
365 $header .= "X-Mailer: SquirrelMail (version $version)" . $rn;
367 /* Do the MIME-stuff */
368 $header .= "MIME-Version: 1.0" . $rn;
370 if (isMultipart($session)) {
371 $header .= 'Content-Type: '.$contentType.' boundary="';
372 $header .= mimeBoundary();
375 $header .= 'Content-Type: ' . $contentType . $rn;
376 $header .= "Content-Transfer-Encoding: 8bit" . $rn;
378 $header .= $rn; // One blank line to separate header and body
380 $headerlength = strlen($header);
383 /* Write the header */
384 fputs ($fp, $header);
386 return $headerlength;
391 function writeBody ($fp, $passedBody, $session, $rn="\r\n") {
392 global $default_charset;
394 $attachmentlength = 0;
396 if (isMultipart($session)) {
397 $body = '--'.mimeBoundary() . $rn;
399 if ($default_charset != "") {
400 $body .= "Content-Type: text/plain; charset=$default_charset".$rn;
403 $body .= "Content-Type: text/plain" . $rn;
406 $body .= "Content-Transfer-Encoding: 8bit" . $rn . $rn;
407 $body .= $passedBody . $rn . $rn;
410 $attachmentlength = attachFiles($fp, $session, $rn);
412 if (!isset($postbody)) {
415 $postbody .= $rn . "--" . mimeBoundary() . "--" . $rn . $rn;
416 fputs ($fp, $postbody);
418 $body = $passedBody . $rn;
421 fputs ($fp, $postbody);
424 return (strlen($body) +
strlen($postbody) +
$attachmentlength);
427 /* Send mail using the sendmail command
429 function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
430 global $sendmail_path, $popuser, $username, $domain;
432 /* Build envelope sender address. Make sure it doesn't contain
433 * spaces or other "weird" chars that would allow a user to
434 * exploit the shell/pipe it is used in.
436 $envelopefrom = getFrom();
437 $envelopefrom = ereg_replace("[[:blank:]]",'', $envelopefrom);
438 $envelopefrom = ereg_replace("[[:space:]]",'', $envelopefrom);
439 $envelopefrom = ereg_replace("[[:cntrl:]]",'', $envelopefrom);
442 * open pipe to sendmail or qmail-inject
443 * (qmail-inject doesn't accept -t param)
445 if (strstr($sendmail_path, "qmail-inject")) {
446 $fp = popen (escapeshellcmd("$sendmail_path -f$envelopefrom"), "w");
448 $fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
451 $headerlength = write822Header ($fp, $t, $c, $b, $subject,
452 $more_headers, $session, "\n");
453 $bodylength = writeBody($fp, $body, $session, "\n");
457 return ($headerlength +
$bodylength);
460 function smtpReadData($smtpConnection) {
461 $read = fgets($smtpConnection, 1024);
465 $data[$counter] = $read;
466 $read = fgets($smtpConnection, 1024);
471 function sendSMTP($t, $c, $b, $subject, $body, $more_headers, $session) {
472 global $username, $popuser, $domain, $version, $smtpServerAddress,
473 $smtpPort, $data_dir, $color, $use_authenticated_smtp, $identity,
476 $to = expandRcptAddrs(parseAddrs($t));
477 $cc = expandRcptAddrs(parseAddrs($c));
478 $bcc = expandRcptAddrs(parseAddrs($b));
479 if (isset($identity) && $identity != 'default') {
480 $from_addr = getPref($data_dir, $username,
481 'email_address' . $identity);
484 $from_addr = getPref($data_dir, $username, 'email_address');
488 $from_addr = "$popuser@$domain";
491 /* POP3 BEFORE SMTP CODE HERE */
492 global $pop_before_smtp;
493 if (isset($pop_before_smtp) && $pop_before_smtp === true) {
494 if (!isset($pop_port)) {
497 if (!isset($pop_server)) {
498 $pop_server = $smtpServerAddress; /* usually the same host! */
500 $popConnection = fsockopen($pop_server, $pop_port, $err_no, $err_str);
501 if (!$popConnection) {
502 error_log("Error connecting to POP Server ($pop_server:$pop_port)"
503 . " $err_no : $err_str");
505 $tmp = fgets($popConnection, 1024); /* banner */
506 if (!eregi("^\+OK", $tmp, $regs)) {
509 fputs($popConnection, "USER $username\r\n");
510 $tmp = fgets($popConnection, 1024);
511 if (!eregi("^\+OK", $tmp, $regs)) {
514 fputs($popConnection, 'PASS ' . OneTimePadDecrypt($key, $onetimepad) . "\r\n");
515 $tmp = fgets($popConnection, 1024);
516 if (!eregi("^\+OK", $tmp, $regs)) {
519 fputs($popConnection, "QUIT\r\n"); /* log off */
520 fclose($popConnection);
524 $smtpConnection = fsockopen($smtpServerAddress, $smtpPort,
525 $errorNumber, $errorString);
526 if (!$smtpConnection) {
527 echo 'Error connecting to SMTP Server.<br>';
528 echo "$errorNumber : $errorString<br>";
531 $tmp = fgets($smtpConnection, 1024);
532 if (errorCheck($tmp, $smtpConnection)!=5) {
536 $to_list = getLineOfAddrs($to);
537 $cc_list = getLineOfAddrs($cc);
539 /* Lets introduce ourselves */
540 if (! isset ($use_authenticated_smtp)
541 ||
$use_authenticated_smtp == false) {
542 fputs($smtpConnection, "HELO $domain\r\n");
543 $tmp = fgets($smtpConnection, 1024);
544 if (errorCheck($tmp, $smtpConnection)!=5) return(0);
546 fputs($smtpConnection, "EHLO $domain\r\n");
547 $tmp = fgets($smtpConnection, 1024);
548 if (errorCheck($tmp, $smtpConnection)!=5) return(0);
550 fputs($smtpConnection, "AUTH LOGIN\r\n");
551 $tmp = fgets($smtpConnection, 1024);
552 if (errorCheck($tmp, $smtpConnection)!=5) {
556 fputs($smtpConnection, base64_encode ($username) . "\r\n");
557 $tmp = fgets($smtpConnection, 1024);
558 if (errorCheck($tmp, $smtpConnection)!=5) {
562 fputs($smtpConnection, base64_encode
563 (OneTimePadDecrypt($key, $onetimepad)) . "\r\n");
564 $tmp = fgets($smtpConnection, 1024);
565 if (errorCheck($tmp, $smtpConnection)!=5) {
570 /* Ok, who is sending the message? */
571 fputs($smtpConnection, "MAIL FROM: <$from_addr>\r\n");
572 $tmp = fgets($smtpConnection, 1024);
573 if (errorCheck($tmp, $smtpConnection)!=5) {
577 /* send who the recipients are */
578 for ($i = 0; $i < count($to); $i++
) {
579 fputs($smtpConnection, "RCPT TO: $to[$i]\r\n");
580 $tmp = fgets($smtpConnection, 1024);
581 if (errorCheck($tmp, $smtpConnection)!=5) {
585 for ($i = 0; $i < count($cc); $i++
) {
586 fputs($smtpConnection, "RCPT TO: $cc[$i]\r\n");
587 $tmp = fgets($smtpConnection, 1024);
588 if (errorCheck($tmp, $smtpConnection)!=5) {
592 for ($i = 0; $i < count($bcc); $i++
) {
593 fputs($smtpConnection, "RCPT TO: $bcc[$i]\r\n");
594 $tmp = fgets($smtpConnection, 1024);
595 if (errorCheck($tmp, $smtpConnection)!=5) {
600 /* Lets start sending the actual message */
601 fputs($smtpConnection, "DATA\r\n");
602 $tmp = fgets($smtpConnection, 1024);
603 if (errorCheck($tmp, $smtpConnection)!=5) {
607 /* Send the message */
608 $headerlength = write822Header ($smtpConnection, $t, $c, $b,
609 $subject, $more_headers, $session);
610 $bodylength = writeBody($smtpConnection, $body, $session);
612 fputs($smtpConnection, ".\r\n"); /* end the DATA part */
613 $tmp = fgets($smtpConnection, 1024);
614 $num = errorCheck($tmp, $smtpConnection, true);
619 fputs($smtpConnection, "QUIT\r\n"); /* log off */
621 fclose($smtpConnection);
623 return ($headerlength +
$bodylength);
627 function errorCheck($line, $smtpConnection, $verbose = false) {
628 global $color, $compose_new_win;
630 /* Read new lines on a multiline response */
632 while(ereg("^[0-9]+-", $line)) {
633 $line = fgets($smtpConnection, 1024);
640 $err_num = substr($line, 0, strpos($line, " "));
642 case 500: $message = 'Syntax error; command not recognized';
645 case 501: $message = 'Syntax error in parameters or arguments';
648 case 502: $message = 'Command not implemented';
651 case 503: $message = 'Bad sequence of commands';
654 case 504: $message = 'Command parameter not implemented';
658 case 211: $message = 'System status, or system help reply';
661 case 214: $message = 'Help message';
665 case 220: $message = 'Service ready';
668 case 221: $message = 'Service closing transmission channel';
672 case 421: $message = 'Service not available, closing chanel';
678 case 250: $message = 'Requested mail action okay, completed';
681 case 251: $message = 'User not local; will forward';
684 case 334: return(5); break;
685 case 450: $message = 'Requested mail action not taken: mailbox unavailable';
688 case 550: $message = 'Requested action not taken: mailbox unavailable';
691 case 451: $message = 'Requested action aborted: error in processing';
694 case 551: $message = 'User not local; please try forwarding';
697 case 452: $message = 'Requested action not taken: insufficient system storage';
700 case 552: $message = 'Requested mail action aborted: exceeding storage allocation';
703 case 553: $message = 'Requested action not taken: mailbox name not allowed';
706 case 354: $message = 'Start mail input; end with .';
709 case 554: $message = 'Transaction failed';
712 default: $message = 'Unknown response: '. nl2br(htmlspecialchars($lines));
719 include_once('../functions/page_header.php');
720 if ($compose_new_win == '1') {
721 compose_Header($color, 'None');
724 displayPageHeader($color, 'None');
726 include_once('../functions/display_messages.php');
727 $lines = nl2br(htmlspecialchars($lines));
728 $msg = $message . "<br>\nServer replied: $lines";
729 plain_error_message($msg, $color);
731 if (! $verbose) return $status;
735 /* create new reference header per rfc2822 */
737 function calculate_references($refs, $inreplyto, $old_reply_to) {
740 for ($i=1;$i<count($refs[0]);$i++
) {
741 if (!empty($refs[0][$i])) {
742 if (preg_match("/^References:(.+)$/", $refs[0][$i], $regs)) {
743 $refer = trim($regs[1]);
746 $refer .= ' ' . trim($refs[0][$i]);
750 $refer = trim($refer);
751 if (strlen($refer) > 2) {
752 $refer .= ' ' . $inreplyto;
755 if (!empty($old_reply_to)) {
756 $refer .= $old_reply_to . ' ' . $inreplyto;
759 $refer .= $inreplyto;
766 function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
767 $prio = 3, $session) {
768 global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad,
769 $data_dir, $username, $domain, $key, $version, $sent_folder,
770 $imapServerAddress, $imapPort, $default_use_priority, $more_headers,
771 $request_mdn, $request_dr;
773 $more_headers = Array();
775 do_hook('smtp_send');
777 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
780 if (isset($reply_id) && $reply_id) {
781 sqimap_mailbox_select ($imap_stream, $mailbox);
782 sqimap_messages_flag ($imap_stream, $reply_id, $reply_id, 'Answered');
784 /* Insert In-Reply-To and References headers if the
785 * message-id of the message we reply to is set (longer than "<>")
786 * The References header should really be the old Referenced header
787 * with the message ID appended, and now it is (jmunro)
789 $sid = sqimap_session_id();
790 $query = "$sid FETCH $reply_id (BODY.PEEK[HEADER.FIELDS (Message-Id In-Reply-To)])\r\n";
791 fputs ($imap_stream, $query);
792 $read = sqimap_read_data($imap_stream, $sid, true, $response, $message);
796 foreach ($read as $r) {
797 if (preg_match("/^message-id:(.*)/iA", $r, $regs)) {
798 $message_id = trim($regs[1]);
800 if (preg_match("/^in-reply-to:(.*)/iA", $r, $regs)) {
801 $in_reply_to = trim($regs[1]);
805 if(strlen($message_id) > 2) {
806 $refs = get_reference_header ($imap_stream, $reply_id);
807 $inreplyto = $message_id;
808 $old_reply_to = $in_reply_to;
809 $refer = calculate_references ($refs, $inreplyto, $old_reply_to);
810 $more_headers['In-Reply-To'] = $inreplyto;
811 $more_headers['References'] = $refer;
815 if ($default_use_priority) {
816 $more_headers = array_merge($more_headers, createPriorityHeaders($prio));
820 if (isset($request_dr)) {
823 if (isset($request_mdn)) {
826 if ( $requestRecipt > 0) {
827 $more_headers = array_merge($more_headers, createReceiptHeaders($requestRecipt));
830 /* In order to remove the problem of users not able to create
831 * messages with "." on a blank line, RFC821 has made provision
832 * in section 4.5.2 (Transparency).
834 $body = ereg_replace("\n\\.", "\n..", $body);
835 $body = ereg_replace("^\\.", "..", $body);
837 /* this is to catch all plain \n instances and
838 * replace them with \r\n. All newlines were converted
839 * into just \n inside the compose.php file.
840 * But only if delimiter is, in fact, \r\n.
844 $more_headers["Content-Type"] = "multipart/report; ".
845 "report-type=disposition-notification;";
849 $length = sendSendmail($t, $c, $b, $subject, $body, $more_headers,
852 $body = ereg_replace("\n", "\r\n", $body);
853 $length = sendSMTP($t, $c, $b, $subject, $body, $more_headers,
856 if (sqimap_mailbox_exists ($imap_stream, $sent_folder)) {
857 if ($useSendmail) $body = ereg_replace("\n", "\r\n", $body);
858 sqimap_append ($imap_stream, $sent_folder, $length);
859 write822Header ($imap_stream, $t, $c, $b, $subject, $more_headers,
861 writeBody ($imap_stream, $body, $session);
862 sqimap_append_done ($imap_stream);
864 sqimap_logout($imap_stream);
865 /* Delete the files uploaded for attaching (if any).
866 * only if $length != 0 (if there was no error)
869 ClearAttachments($session);
875 function createPriorityHeaders($prio) {
876 $prio_headers = Array();
877 $prio_headers['X-Priority'] = $prio;
880 case 1: $prio_headers['Importance'] = 'High';
881 $prio_headers['X-MSMail-Priority'] = 'High';
884 case 3: $prio_headers['Importance'] = 'Normal';
885 $prio_headers['X-MSMail-Priority'] = 'Normal';
889 $prio_headers['Importance'] = 'Low';
890 $prio_headers['X-MSMail-Priority'] = 'Low';
893 return $prio_headers;
896 function createReceiptHeaders($receipt) {
898 GLOBAL $data_dir, $username, $identity, $popuser, $domain;
900 $receipt_headers = Array();
901 if (isset($identity) && $identity != 'default') {
902 $from = getPref($data_dir, $username, 'full_name' . $identity);
903 $from_addr = getPref($data_dir, $username, 'email_address' . $identity);
905 $from = getPref($data_dir, $username, 'full_name');
906 $from_addr = getPref($data_dir, $username, 'email_address');
908 if ($from_addr == '') {
909 $from_addr = $popuser.'@'.$domain;
913 $from = "<$from_addr>";
916 $from = '"' . encodeHeader($from) . "\" <$from_addr>";
922 $receipt_headers["Return-Receipt-To"] = $from;
928 $receipt_headers["X-Confirm-Reading-To"] = $from;
930 $receipt_headers["Disposition-Notification-To"] = $from;
932 return $receipt_headers;
935 /* Figure out what the 'From:' address is
939 global $username, $popuser, $domain, $data_dir, $identity;
940 if (isset($identity) && $identity != 'default') {
941 $from_addr = getPref($data_dir, $username,
942 'email_address' . $identity);
945 $from_addr = getPref($data_dir, $username, 'email_address');
949 $from_addr = "$popuser@$domain";