From e12256041f08f9e254885450572bd27033307ab0 Mon Sep 17 00:00:00 2001 From: centaurix Date: Sat, 11 May 2002 15:06:03 +0000 Subject: [PATCH] added patch from feature request to use getFrom function. now envelopes are set correctly to the from address (not just : username@domain) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2817 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/smtp.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/functions/smtp.php b/functions/smtp.php index 24f92d03..5e75527d 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -263,16 +263,11 @@ function write822Header ($fp, $t, $c, $b, $subject, $more_headers, $session, $rn if (isset($identity) && $identity != 'default') { $reply_to = getPref($data_dir, $username, 'reply_to' . $identity); $from = getPref($data_dir, $username, 'full_name' . $identity); - $from_addr = getPref($data_dir, $username, - 'email_address' . $identity); + $from_addr = getFrom(); } else { $reply_to = getPref($data_dir, $username, 'reply_to'); $from = getPref($data_dir, $username, 'full_name'); - $from_addr = getPref($data_dir, $username, 'email_address'); - } - - if ($from_addr == '') { - $from_addr = $popuser.'@'.$domain; + $from_addr = getFrom(); } $to_list = getLineOfAddrs($to); @@ -438,7 +433,7 @@ function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) { * spaces or other "weird" chars that would allow a user to * exploit the shell/pipe it is used in. */ - $envelopefrom = "$popuser@$domain"; + $envelopefrom = getFrom(); $envelopefrom = ereg_replace("[[:blank:]]",'', $envelopefrom); $envelopefrom = ereg_replace("[[:space:]]",'', $envelopefrom); $envelopefrom = ereg_replace("[[:cntrl:]]",'', $envelopefrom); @@ -458,7 +453,7 @@ function sendSendmail($t, $c, $b, $subject, $body, $more_headers, $session) { $bodylength = writeBody($fp, $body, $session, "\n"); pclose($fp); - + return ($headerlength + $bodylength); } @@ -937,5 +932,24 @@ function createReceiptHeaders($receipt) { return $receipt_headers; } +/* Figure out what the 'From:' address is + */ + +function getFrom() { + global $username, $popuser, $domain, $data_dir, $identity; + if (isset($identity) && $identity != 'default') { + $from_addr = getPref($data_dir, $username, + 'email_address' . $identity); + } + else { + $from_addr = getPref($data_dir, $username, 'email_address'); + } + + if (!$from_addr) { + $from_addr = "$popuser@$domain"; + } + return $from_addr; +} + ?> -- 2.25.1