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');
35 * Return which separator we should be using.
36 * \r\n for SMTP delivery, just \n for Sendmail.
48 /* Returns true only if this message is multipart */
49 function isMultipart ($session) {
52 foreach ($attachments as $info) {
53 if ($info['session'] == $session) {
60 /* looks up aliases in the addressbook and expands them to
63 * Adds @$domain if it wasn't in the address book and if it
64 * doesn't have an @ symbol in it
66 function expandAddrs ($array) {
69 /* don't show errors -- kinda critical that we don't see
70 * them here since the redirect won't work if we do show them
72 $abook = addressbook_init(false, true);
73 for ($i=0; $i < count($array); $i++
) {
74 $result = $abook->lookup($array[$i]);
76 if (isset($result['email'])) {
77 if (isset($result['name'])) {
78 $ret = '"'.$result['name'].'" ';
80 $ret .= '<'.$result['email'].'>';
85 if (strpos($array[$i], '@') === false) {
86 $array[$i] .= '@' . $domain;
88 $array[$i] = '<' . $array[$i] . '>';
95 /* looks up aliases in the addressbook and expands them to
96 * the RFC 821 valid RCPT address. ie <user@example.com>
97 * Adds @$domain if it wasn't in the address book and if it
98 * doesn't have an @ symbol in it
100 function expandRcptAddrs ($array) {
103 /* don't show errors -- kinda critical that we don't see
104 * them here since the redirect won't work if we do show them
106 $abook = addressbook_init(false, true);
107 for ($i=0; $i < count($array); $i++
) {
108 $result = $abook->lookup($array[$i]);
110 if (isset($result['email'])) {
111 $ret = '<'.$result['email'].'>';
115 if (strpos($array[$i], '@') === false) {
116 $array[$i] .= '@' . $domain;
118 $array[$i] = '<' . $array[$i] . '>';
125 /* Attach the files that are due to be attached
127 function attachFiles ($fp, $session) {
128 global $attachments, $attachment_dir, $username;
133 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
134 if (isMultipart($session)) {
135 foreach ($attachments as $info) {
136 if ($info['session'] == $session) {
137 if (isset($info['type'])) {
138 $filetype = $info['type'];
141 $filetype = 'application/octet-stream';
144 $header = '--' . mimeBoundary() . "$rn";
145 if ( isset($info['remotefilename'])
146 && $info['remotefilename'] != '') {
147 $header .= "Content-Type: $filetype; name=\"" .
148 $info['remotefilename'] . "\"$rn";
149 $header .= "Content-Disposition: attachment; filename=\""
150 . $info['remotefilename'] . "\"$rn";
152 $header .= "Content-Type: $filetype$rn";
156 /* Use 'rb' for NT systems -- read binary
157 * Unix doesn't care -- everything's binary! :-)
160 $filename = $hashed_attachment_dir . '/'
161 . $info['localfilename'];
162 $file = fopen ($filename, 'rb');
163 if (substr($filetype, 0, 5) == 'text/' ||
164 substr($filetype, 0, 8) == 'message/' ) {
166 fputs ($fp, $header);
167 $length +
= strlen($header);
168 while ($tmp = fgets($file, 4096)) {
169 $tmp = str_replace("\r\n", "\n", $tmp);
170 $tmp = str_replace("\r", "\n", $tmp);
172 $tmp = str_replace("\n", "\r\n", $tmp);
175 * Check if the last line has newline ($rn) in it
176 * and append if it doesn't.
178 if (feof($fp) && !strstr($tmp, "$rn")){
182 $length +
= strlen($tmp);
185 $header .= "Content-Transfer-Encoding: base64"
187 fputs ($fp, $header);
188 $length +
= strlen($header);
189 while ($tmp = fread($file, 570)) {
190 $encoded = chunk_split(base64_encode($tmp));
191 $length +
= strlen($encoded);
192 fputs ($fp, $encoded);
202 /* Delete files that are uploaded for attaching
204 function deleteAttachments($session) {
205 global $username, $attachments, $attachment_dir;
206 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
208 $rem_attachments = array();
209 foreach ($attachments as $info) {
210 if ($info['session'] == $session) {
211 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
212 if (file_exists($attached_file)) {
213 unlink($attached_file);
216 $rem_attachments[] = $info;
219 $attachments = $rem_attachments;
222 /* Return a nice MIME-boundary
224 function mimeBoundary () {
225 static $mimeBoundaryString;
227 if ( !isset( $mimeBoundaryString ) ||
228 $mimeBoundaryString == '') {
229 $mimeBoundaryString = '----=_' . date( 'YmdHis' ) . '_' .
230 mt_rand( 10000, 99999 );
233 return $mimeBoundaryString;
236 /* Time offset for correct timezone */
237 function timezone () {
240 $diff_second = date('Z');
242 $diff_second = - $diff_second;
244 if ($diff_second > 0) {
251 $diff_second = abs($diff_second);
253 $diff_hour = floor ($diff_second / 3600);
254 $diff_minute = floor (($diff_second-3600*$diff_hour) / 60);
256 $zonename = '('.strftime('%Z').')';
257 $result = sprintf ("%s%02d%02d %s", $sign, $diff_hour, $diff_minute,
262 /* Print all the needed RFC822 headers */
263 function write822Header ($fp, $t, $c, $b, $subject, $more_headers, $session) {
264 global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
265 global $data_dir, $username, $popuser, $domain, $version, $useSendmail;
266 global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR;
267 global $REMOTE_HOST, $identity;
269 * Get which delimiter we are going to use.
272 /* Storing the header to make sure the header is the same
273 * everytime the header is printed.
275 static $header, $headerlength;
278 $to = expandAddrs(parseAddrs($t));
279 $cc = expandAddrs(parseAddrs($c));
280 $bcc = expandAddrs(parseAddrs($b));
281 if (isset($identity) && $identity != 'default') {
282 $reply_to = getPref($data_dir, $username, 'reply_to' . $identity);
283 $from = getPref($data_dir, $username, 'full_name' . $identity);
284 $from_addr = getPref($data_dir, $username,
285 'email_address' . $identity);
287 $reply_to = getPref($data_dir, $username, 'reply_to');
288 $from = getPref($data_dir, $username, 'full_name');
289 $from_addr = getPref($data_dir, $username, 'email_address');
292 if ($from_addr == '') {
293 $from_addr = $popuser.'@'.$domain;
296 $to_list = getLineOfAddrs($to);
297 $cc_list = getLineOfAddrs($cc);
298 $bcc_list = getLineOfAddrs($bcc);
300 /* Encoding 8-bit characters and making from line */
301 $subject = encodeHeader($subject);
303 $from = "<$from_addr>";
306 $from = '"' . encodeHeader($from) . "\" <$from_addr>";
309 /* This creates an RFC 822 date */
310 $date = date("D, j M Y H:i:s ", mktime()) . timezone();
312 /* Create a message-id */
313 $message_id = '<' . $REMOTE_PORT . '.' . $REMOTE_ADDR . '.';
314 $message_id .= time() . '.squirrel@' . $SERVER_NAME .'>';
316 /* Make an RFC822 Received: line */
317 if (isset($REMOTE_HOST)) {
318 $received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
321 $received_from = $REMOTE_ADDR;
324 if (isset($HTTP_VIA) ||
isset ($HTTP_X_FORWARDED_FOR)) {
325 if ($HTTP_X_FORWARDED_FOR == '') {
326 $HTTP_X_FORWARDED_FOR = 'unknown';
328 $received_from .= " (proxying for $HTTP_X_FORWARDED_FOR)";
331 $header = "Received: from $received_from" . $rn;
332 $header .= " (SquirrelMail authenticated user $username)" . $rn;
333 $header .= " by $SERVER_NAME with HTTP;" . $rn;
334 $header .= " $date" . $rn;
336 /* Insert the rest of the header fields */
337 $header .= "Message-ID: $message_id" . $rn;
338 $header .= "Date: $date" . $rn;
339 $header .= "Subject: $subject" . $rn;
340 $header .= "From: $from" . $rn;
341 $header .= "To: $to_list" . $rn; // Who it's TO
343 if (isset($more_headers["Content-Type"])) {
344 $contentType = $more_headers["Content-Type"];
345 unset($more_headers["Content-Type"]);
348 if (isMultipart($session)) {
349 $contentType = "multipart/mixed;";
352 if ($default_charset != '') {
353 $contentType = 'text/plain; charset='.$default_charset;
356 $contentType = 'text/plain;';
361 /* Insert headers from the $more_headers array */
362 if(is_array($more_headers)) {
363 reset($more_headers);
364 while(list($h_name, $h_val) = each($more_headers)) {
365 $header .= sprintf("%s: %s%s", $h_name, $h_val, $rn);
370 $header .= "Cc: $cc_list" . $rn; // Who the CCs are
373 if ($reply_to != '') {
374 $header .= "Reply-To: $reply_to" . $rn;
379 // BCCs is removed from header by sendmail
380 $header .= "Bcc: $bcc_list" . $rn;
384 /* Identify SquirrelMail */
385 $header .= "X-Mailer: SquirrelMail (version $version)" . $rn;
387 /* Do the MIME-stuff */
388 $header .= "MIME-Version: 1.0" . $rn;
390 if (isMultipart($session)) {
391 $header .= 'Content-Type: '.$contentType.' boundary="';
392 $header .= mimeBoundary();
395 $header .= 'Content-Type: ' . $contentType . $rn;
396 $header .= "Content-Transfer-Encoding: 8bit" . $rn;
398 $header .= $rn; // One blank line to separate header and body
400 $headerlength = strlen($header);
403 /* Write the header */
404 fputs ($fp, $header);
406 return $headerlength;
411 function writeBody ($fp, $passedBody, $session) {
412 global $default_charset;
418 $attachmentlength = 0;
420 if (isMultipart($session)) {
421 $body = '--'.mimeBoundary() . $rn;
423 if ($default_charset != "") {
424 $body .= "Content-Type: text/plain; charset=$default_charset".$rn;
427 $body .= "Content-Type: text/plain" . $rn;
430 $body .= "Content-Transfer-Encoding: 8bit" . $rn . $rn;
431 $body .= $passedBody . $rn . $rn;
434 $attachmentlength = attachFiles($fp, $session);
436 if (!isset($postbody)) {
439 $postbody .= $rn . "--" . mimeBoundary() . "--" . $rn . $rn;
440 fputs ($fp, $postbody);
442 $body = $passedBody . $rn;
445 fputs ($fp, $postbody);
448 return (strlen($body) +
strlen($postbody) +
$attachmentlength);
451 /* Send mail using the sendmail command
453 function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) {
454 global $sendmail_path, $popuser, $username, $domain;
456 /* Build envelope sender address. Make sure it doesn't contain
457 * spaces or other "weird" chars that would allow a user to
458 * exploit the shell/pipe it is used in.
460 $envelopefrom = "$popuser@$domain";
461 $envelopefrom = ereg_replace("[[:blank:]]",'', $envelopefrom);
462 $envelopefrom = ereg_replace("[[:space:]]",'', $envelopefrom);
463 $envelopefrom = ereg_replace("[[:cntrl:]]",'', $envelopefrom);
466 * open pipe to sendmail or qmail-inject
467 * (qmail-inject doesn't accept -t param)
469 if (strstr($sendmail_path, "qmail-inject")) {
470 $fp = popen (escapeshellcmd("$sendmail_path -f$envelopefrom"), "w");
472 $fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
475 $headerlength = write822Header ($fp, $t, $c, $b, $subject,
476 $more_headers, $session);
477 $bodylength = writeBody($fp, $body, $session);
481 return ($headerlength +
$bodylength);
484 function smtpReadData($smtpConnection) {
485 $read = fgets($smtpConnection, 1024);
489 $data[$counter] = $read;
490 $read = fgets($smtpConnection, 1024);
495 function sendSMTP($t, $c, $b, $subject, $body, $more_headers, $session) {
496 global $username, $popuser, $domain, $version, $smtpServerAddress,
497 $smtpPort, $data_dir, $color, $use_authenticated_smtp, $identity,
500 $to = expandRcptAddrs(parseAddrs($t));
501 $cc = expandRcptAddrs(parseAddrs($c));
502 $bcc = expandRcptAddrs(parseAddrs($b));
503 if (isset($identity) && $identity != 'default') {
504 $from_addr = getPref($data_dir, $username,
505 'email_address' . $identity);
508 $from_addr = getPref($data_dir, $username, 'email_address');
512 $from_addr = "$popuser@$domain";
515 /* POP3 BEFORE SMTP CODE HERE */
516 global $pop_before_smtp;
517 if (isset($pop_before_smtp) && $pop_before_smtp === true) {
518 if (!isset($pop_port)) {
521 if (!isset($pop_server)) {
522 $pop_server = $smtpServerAddress; /* usually the same host! */
524 $popConnection = fsockopen($pop_server, $pop_port, $err_no, $err_str);
525 if (!$popConnection) {
526 error_log("Error connecting to POP Server ($pop_server:$pop_port)"
527 . " $err_no : $err_str");
529 $tmp = fgets($popConnection, 1024); /* banner */
530 if (!eregi("^\+OK", $tmp, $regs)) {
533 fputs($popConnection, "USER $username\r\n");
534 $tmp = fgets($popConnection, 1024);
535 if (!eregi("^\+OK", $tmp, $regs)) {
538 fputs($popConnection, 'PASS ' . OneTimePadDecrypt($key, $onetimepad) . "\r\n");
539 $tmp = fgets($popConnection, 1024);
540 if (!eregi("^\+OK", $tmp, $regs)) {
543 fputs($popConnection, "QUIT\r\n"); /* log off */
544 fclose($popConnection);
548 $smtpConnection = fsockopen($smtpServerAddress, $smtpPort,
549 $errorNumber, $errorString);
550 if (!$smtpConnection) {
551 echo 'Error connecting to SMTP Server.<br>';
552 echo "$errorNumber : $errorString<br>";
555 $tmp = fgets($smtpConnection, 1024);
556 if (errorCheck($tmp, $smtpConnection)!=5) {
560 $to_list = getLineOfAddrs($to);
561 $cc_list = getLineOfAddrs($cc);
563 /* Lets introduce ourselves */
564 if (! isset ($use_authenticated_smtp)
565 ||
$use_authenticated_smtp == false) {
566 fputs($smtpConnection, "HELO $domain\r\n");
567 $tmp = fgets($smtpConnection, 1024);
568 if (errorCheck($tmp, $smtpConnection)!=5) return(0);
570 fputs($smtpConnection, "EHLO $domain\r\n");
571 $tmp = fgets($smtpConnection, 1024);
572 if (errorCheck($tmp, $smtpConnection)!=5) return(0);
574 fputs($smtpConnection, "AUTH LOGIN\r\n");
575 $tmp = fgets($smtpConnection, 1024);
576 if (errorCheck($tmp, $smtpConnection)!=5) {
580 fputs($smtpConnection, base64_encode ($username) . "\r\n");
581 $tmp = fgets($smtpConnection, 1024);
582 if (errorCheck($tmp, $smtpConnection)!=5) {
586 fputs($smtpConnection, base64_encode
587 (OneTimePadDecrypt($key, $onetimepad)) . "\r\n");
588 $tmp = fgets($smtpConnection, 1024);
589 if (errorCheck($tmp, $smtpConnection)!=5) {
594 /* Ok, who is sending the message? */
595 fputs($smtpConnection, "MAIL FROM: <$from_addr>\r\n");
596 $tmp = fgets($smtpConnection, 1024);
597 if (errorCheck($tmp, $smtpConnection)!=5) {
601 /* send who the recipients are */
602 for ($i = 0; $i < count($to); $i++
) {
603 fputs($smtpConnection, "RCPT TO: $to[$i]\r\n");
604 $tmp = fgets($smtpConnection, 1024);
605 if (errorCheck($tmp, $smtpConnection)!=5) {
609 for ($i = 0; $i < count($cc); $i++
) {
610 fputs($smtpConnection, "RCPT TO: $cc[$i]\r\n");
611 $tmp = fgets($smtpConnection, 1024);
612 if (errorCheck($tmp, $smtpConnection)!=5) {
616 for ($i = 0; $i < count($bcc); $i++
) {
617 fputs($smtpConnection, "RCPT TO: $bcc[$i]\r\n");
618 $tmp = fgets($smtpConnection, 1024);
619 if (errorCheck($tmp, $smtpConnection)!=5) {
624 /* Lets start sending the actual message */
625 fputs($smtpConnection, "DATA\r\n");
626 $tmp = fgets($smtpConnection, 1024);
627 if (errorCheck($tmp, $smtpConnection)!=5) {
631 /* Send the message */
632 $headerlength = write822Header ($smtpConnection, $t, $c, $b,
633 $subject, $more_headers, $session);
634 $bodylength = writeBody($smtpConnection, $body, $session);
636 fputs($smtpConnection, ".\r\n"); /* end the DATA part */
637 $tmp = fgets($smtpConnection, 1024);
638 $num = errorCheck($tmp, $smtpConnection, true);
643 fputs($smtpConnection, "QUIT\r\n"); /* log off */
645 fclose($smtpConnection);
647 return ($headerlength +
$bodylength);
651 function errorCheck($line, $smtpConnection, $verbose = false) {
652 global $color, $compose_new_win;
654 /* Read new lines on a multiline response */
656 while(ereg("^[0-9]+-", $line)) {
657 $line = fgets($smtpConnection, 1024);
664 $err_num = substr($line, 0, strpos($line, " "));
666 case 500: $message = 'Syntax error; command not recognized';
669 case 501: $message = 'Syntax error in parameters or arguments';
672 case 502: $message = 'Command not implemented';
675 case 503: $message = 'Bad sequence of commands';
678 case 504: $message = 'Command parameter not implemented';
682 case 211: $message = 'System status, or system help reply';
685 case 214: $message = 'Help message';
689 case 220: $message = 'Service ready';
692 case 221: $message = 'Service closing transmission channel';
696 case 421: $message = 'Service not available, closing chanel';
702 case 250: $message = 'Requested mail action okay, completed';
705 case 251: $message = 'User not local; will forward';
708 case 334: return(5); break;
709 case 450: $message = 'Requested mail action not taken: mailbox unavailable';
712 case 550: $message = 'Requested action not taken: mailbox unavailable';
715 case 451: $message = 'Requested action aborted: error in processing';
718 case 551: $message = 'User not local; please try forwarding';
721 case 452: $message = 'Requested action not taken: insufficient system storage';
724 case 552: $message = 'Requested mail action aborted: exceeding storage allocation';
727 case 553: $message = 'Requested action not taken: mailbox name not allowed';
730 case 354: $message = 'Start mail input; end with .';
733 case 554: $message = 'Transaction failed';
736 default: $message = 'Unknown response: '. nl2br(htmlspecialchars($lines));
743 include_once('../functions/page_header.php');
744 if ($compose_new_win == '1') {
745 compose_Header($color, 'None');
748 displayPageHeader($color, 'None');
750 include_once('../functions/display_messages.php');
751 $lines = nl2br(htmlspecialchars($lines));
752 $msg = $message . "<br>\nServer replied: $lines";
753 plain_error_message($msg, $color);
755 if (! $verbose) return $status;
759 /* create new reference header per rfc2822 */
761 function calculate_references($refs, $inreplyto, $old_reply_to) {
767 for ($i=1;$i<count($refs[0]);$i++
) {
768 if (!empty($refs[0][$i])) {
769 if (preg_match("/^References:(.+)$/", $refs[0][$i], $regs)) {
770 $refer = trim($regs[1]);
773 $refer .= ' ' . trim($refs[0][$i]);
777 $refer = trim($refer);
778 if (strlen($refer) > 2) {
779 $refer .= ' ' . $inreplyto;
782 if (!empty($old_reply_to)) {
783 $refer .= $old_reply_to . ' ' . $inreplyto;
786 $refer .= $inreplyto;
790 $refer = str_replace(' ', "$rn ", $refer);
794 function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
795 $prio = 3, $session) {
796 global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad,
797 $data_dir, $username, $domain, $key, $version, $sent_folder,
798 $imapServerAddress, $imapPort, $default_use_priority, $more_headers,
799 $request_mdn, $request_dr;
805 $more_headers = Array();
807 do_hook('smtp_send');
809 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
812 if (isset($reply_id) && $reply_id) {
813 sqimap_mailbox_select ($imap_stream, $mailbox);
814 sqimap_messages_flag ($imap_stream, $reply_id, $reply_id, 'Answered');
816 /* Insert In-Reply-To and References headers if the
817 * message-id of the message we reply to is set (longer than "<>")
818 * The References header should really be the old Referenced header
819 * with the message ID appended, and now it is (jmunro)
821 $hdr = sqimap_get_small_header ($imap_stream, $reply_id, false);
822 if(strlen($hdr->message_id
) > 2) {
823 $refs = get_reference_header ($imap_stream, $reply_id);
824 $inreplyto = $hdr->message_id
;
825 $old_reply_to = $hdr->inrepto
;
826 $refer = calculate_references ($refs, $inreplyto, $old_reply_to);
827 $more_headers['In-Reply-To'] = $inreplyto;
828 $more_headers['References'] = $refer;
831 if ($default_use_priority) {
832 $more_headers = array_merge($more_headers, createPriorityHeaders($prio));
836 if (isset($request_dr)) {
839 if (isset($request_mdn)) {
842 if ( $requestRecipt > 0) {
843 $more_headers = array_merge($more_headers, createReceiptHeaders($requestRecipt));
846 /* In order to remove the problem of users not able to create
847 * messages with "." on a blank line, RFC821 has made provision
848 * in section 4.5.2 (Transparency).
850 $body = ereg_replace("\n\\.", "\n..", $body);
851 $body = ereg_replace("^\\.", "..", $body);
853 /* this is to catch all plain \n instances and
854 * replace them with \r\n. All newlines were converted
855 * into just \n inside the compose.php file.
856 * But only if delimiter is, in fact, \r\n.
859 $body = ereg_replace("\n", "\r\n", $body);
863 $more_headers["Content-Type"] = "multipart/report; ".
864 "report-type=disposition-notification;";
868 $length = sendSendmail($t, $c, $b, $subject, $body, $more_headers,
871 $length = sendSMTP($t, $c, $b, $subject, $body, $more_headers,
874 if (sqimap_mailbox_exists ($imap_stream, $sent_folder)) {
875 sqimap_append ($imap_stream, $sent_folder, $length);
876 write822Header ($imap_stream, $t, $c, $b, $subject, $more_headers,
878 writeBody ($imap_stream, $body, $session);
879 sqimap_append_done ($imap_stream);
881 sqimap_logout($imap_stream);
882 /* Delete the files uploaded for attaching (if any).
883 * only if $length != 0 (if there was no error)
886 ClearAttachments($session);
892 function createPriorityHeaders($prio) {
893 $prio_headers = Array();
894 $prio_headers['X-Priority'] = $prio;
897 case 1: $prio_headers['Importance'] = 'High';
898 $prio_headers['X-MSMail-Priority'] = 'High';
901 case 3: $prio_headers['Importance'] = 'Normal';
902 $prio_headers['X-MSMail-Priority'] = 'Normal';
906 $prio_headers['Importance'] = 'Low';
907 $prio_headers['X-MSMail-Priority'] = 'Low';
910 return $prio_headers;
913 function createReceiptHeaders($receipt) {
915 GLOBAL $data_dir, $username, $identity, $popuser, $domain;
917 $receipt_headers = Array();
918 if (isset($identity) && $identity != 'default') {
919 $from = getPref($data_dir, $username, 'full_name' . $identity);
920 $from_addr = getPref($data_dir, $username, 'email_address' . $identity);
922 $from = getPref($data_dir, $username, 'full_name');
923 $from_addr = getPref($data_dir, $username, 'email_address');
925 if ($from_addr == '') {
926 $from_addr = $popuser.'@'.$domain;
930 $from = "<$from_addr>";
933 $from = '"' . encodeHeader($from) . "\" <$from_addr>";
939 $receipt_headers["Return-Receipt-To"] = $from;
945 $receipt_headers["X-Confirm-Reading-To"] = $from;
947 $receipt_headers["Disposition-Notification-To"] = $from;
949 return $receipt_headers;