NYCPHP Meetup

NYPHP.org

[nycphp-talk] bounced email and Mail::send()

Anirudh Zala arzala at gmail.com
Mon Oct 17 00:54:19 EDT 2005


Normally you do not require to set header "Return-path" because return 
path address is automatically taken by Sendmail as the user who sends 
emails. Hence in your case it is "apache" when when sending mail from 
web and "shell user" while sending mail from shell.

Hence now you have only 2 options. To set above header in desired way, 
do not pass "Return-path" header while sending email. Instead in mail 
function use 5th arguments like below.

mail('To mail', 'Subject', 'Message', 'All required header', '-f 
bounce at someone.some');

This fifth parameter (was added in PHP 4.0.5) is your Return-Path. Here 
"bounce at someone.some" is your bounce mail address. Alternatively you can 
set permanent address in your php.ini or httpd.conf like below.

/usr/sbin/sendmail -f 'bounce at someone.some'

Please note that I have not tested above, so you have to try. But it 
will work most probably or you may have to change syntax according to 
php.ini or httpd.conf.

And sending mail from shell, invoke sendail command by using "-f" option 
and specify bounced email adress. See below.

[...]# /usr/sbin/sendmail -f 'bounce at someone.some' REST OF ARGUMENTS

Thanks

Anirudh Zala

---------------------------------
Anirudh Zala (Production Manager)
Ph: +91 281 245 1894
anirudh at aspl.in
http://www.aspl.in
---------------------------------



Allen Shaw wrote:

>Anirudh Zala wrote:
>  
>
>>You already have paramater "Return-path" in your header so it should 
>>work. Do you use proper syntex in writing your all headers? Moreover try 
>>to add 1 more parameter "Errors-To" to your header string and then check 
>>whether it works or not. I have not tested it, but normally it works.
>>
>>Thanks
>>
>>Zala
>>    
>>
>
>Well, after further review, it appears it *did* work after all, but not 
>in the way I expected.  Bounced mail came back into my CLI user's 
>mailbox (let's call it "shell_PHP_user at example.com"), not the one marked 
>in the headers ("me at example.com"). In fact, the headers on most of this 
>bounced mail show the original message as coming from 
>"shell_PHP_user at localhost".
>
>I'm guessing there's some sendmail tweaking to be done here. But still, 
>shouldn't the headers I pass to Mail::send() be the same headers that 
>get attached to the mail?
>
>For the sake of detail, here are the first few header lines of the email 
>that's being sent -- notice that 'shell_PHP_user' is being used on the 
>lines above, while 'me' is being used on the lower lines:
>  
>
>>From - Sat Oct 15 06:12:13 2005
>>X-Account-Key: account3
>>X-UIDL: 4350e40d00000001
>>X-Mozilla-Status: 0001
>>X-Mozilla-Status2: 10400000
>>Return-Path: <shell_PHP_user at example.com > Received: (from shell_PHP_user at localhost)
>>	by example.com (8.11.6/8.11.6) id j9FBC7J03635;
>>	Sat, 15 Oct 2005 06:12:08 -0500
>>Date: Sat, 15 Oct 2005 06:12:08 -0500
>>Message-Id: <200510151112.j9FBC7J03635 at example.com>
>>To: badaddress at other.example.com, me at example.com
>>Subject: test email
>>MIME-Version: 1.0
>>From: <me at example.com>
>>Reply-To: <me at example.com>
>>Return-Receipt-To: <me at example.com>
>>Errors-To: <me at example.com>
>>Content-Type: multipart/mixed;
>>	boundary="=_24450f0ce176f5580ea337c3fe3ec778"
>>Status:   
>>    
>>
>
>That's when I run the script from the command line.  If I run it through 
>the Web, it's all the same except 'apache' is used instead of 
>'shell_PHP_user'.  In any case, somehow the user name is being used 
>instead of the values passed to $mime->headers().  Odd, right?
>
>At this point it's academic, as I've found the bounced mail and know 
>where it's going, but why the heck isn't this mail using the headers I 
>give it?
>
>I'll keep looking and post any answers here as a follow-up.
>
>- Allen
>
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051017/3de800e8/attachment.html>


More information about the talk mailing list