Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does user 'nobody' need permission to send a message with 'Return-Path 1

Status
Not open for further replies.

WMAdam

Programmer
Jun 5, 2002
14
0
0
US
Hi All,
I have a php script that sends email to user-specified email addresses. The problem is, when the message bounces, it bounces back to "nobody@myboxsname". I have a line in the header of the message (in php) that says:
&quot;Return-Path: <myaddress\@mydomain.com>&quot;.
What is interesting is that I can get the return path to change only if i change the default sendmail path for php to: &quot;/usr/sbin/sendmail -t -f myaddress@mydomain.com&quot;
Well thats great except I don't want every message leaving that machine to have that address as a return path!
Is there something I need to set in the sendmail config? Any help is greatly appreciated... I am clearly a sendmail novice.
Thanks!
Adam
 
Usually nobody and apache are users on your system and have a mail box. If mail was never sent to them you won't see the mail box on the server i.e. /var/spool/mail/nobody. You can check to see if &quot;nobody&quot; is a valid user on your system if not, you can do a few different things. One is to create an account for &quot;nobody&quot; or you can create an alias for it and associate it with a real user. Another option is to add it to the virtusertable. If you use the last option, don't forget to hash a new db for it. If you go with the alias option you will need to run newaliases.
 
I appreciate the reply, but I would really like to know how to legitimately change the 'Return-Path' address in the message and have sendmail actually recognize it. It is my believe that it's a permissions or configuration issue with sendmail. I'm not really interested in catching the bounces in a 'nobody' account...
 
Hi WMAdam,

Hope this reply isn't too late.

I have found the the PHP mail() function has 5 arguments. The 5th argument seems to allow one to add arguments to the 'sendmail' command which PHP uses.

So, for example, if you want bounced mail to go to 'myaddress@mydomain.com', you can do something like this in the PHP script:

$success=mail($toaddress,$subject,$message,&quot;From: $from&quot;,&quot;-fmyaddress@mydomain.com&quot;);

to insert the appropriate '-f' argument to sendmail.

Hope this helped. -David
 
The '-f' argument sets the &quot;From&quot; field; how does this relate to Return-path and the question asked here? Also it appears there are some limitations. Reproducing from the man page:

-f name Sets the name of the From: user field (that is, the sender of the mail). -f can only be used by trusted users (normally root, daemon, and network) or if the person you are trying to become is the same as the person you are.
 
So I guess this becomes an issue of letting sendmail trust the 'apache' or 'php' user, whomever is actually executing the script. I am no guru with sendmail, anyone have any hints?
Thanks,
Adam
 
Hi WMAdam,

Sure, I have a hint. :) My hint is to try the suggestion in a previous message and see if it works for you:

$success=mail($toaddress,$subject,$message,&quot;From: $from&quot;,&quot;-fmyaddress@mydomain.com&quot;);

In my version of sendmail (version 8.11.6) on the Linux system I use, the '-f' parameter sends the Return-Path header. As a matter of fact, WMAdam, you yourself said that setting the sendmail command to use -f in PHP global configuration worked for you. Using '-f' in PHP mail()'s 5th parameter does the same thing, but limits its effect to your individual script, rather than for the entire PHP server or webserver.

So, WMAdam, why don't you give this a try?

As further explanation for your benefit, Calator, the manpage on the Linux system I use says this about the '-f' parameter for sendmail:

&quot;-fname
&quot;Sets the name of the ``from'' person (i.e., the envelope sender of the mail). This address may also be used in the From: header if that header is missing during initial submission. The envelope sender address is used as the recipient for delivery status notifications and may also appear in a Return-Path: header. -f should only be used by``trusted'' users (normally root, daemon, and network) or if the person you are trying to become is the same as the person you are. Otherwise, an X-Authentication-Warning header will be added to the message.&quot;

In other words, it will work; it may create an X-Authentication-Warning header, but it will work. Most users won't see the authentication warning.

If you are the system administrator on your system, WMAdam, you can configure sendmail so that 'nobody' is a ''trusted'' user, which will get rid of that warning. But let's first see if this works at all on your system?

Good luck! :)
-David
 
David,

This HAS worked for us. It was a pleasant surprise as it solved an outstanding problem. You've got a star for this.

Maybe you can also advise if there is a flag to use in order to obtain a &quot;read receipt&quot; notification to go to the same address as that used with -f?

Someone advised to use -Nsuccess,failure,delay
this also worked now and returned a delivery notification but no read receipt. This -N flag does not appear to be documented by my man page (Unix)

Thanks
 
Read receipt has to be put in as an extra text field into the header ... officially it is not a totally supported protocol, since the receiver can ignore it, however most people do oblige by it.

i think the header is:
[tt]Disposition-Notification-To: <your email address>[/tt]

maybe :)
 
Jad,

Thanks, but this did not work. No read receipt was being sent back upon reading the message.
 
ahh well :) never mind. i'll look and see if i can work out what the real receipt looks like (i'm sure i have it documented somewhere)

Return-Receipt-To: <your email address>

might/should work ... but sendmails site says the best way to do this is to ask the user to send you confirmation personally :)
 
Jad,

&quot;return-receipt-to&quot; has generated a delivery notification.
We would like to find out if there was a header to obtain a &quot;read receipt&quot;. Thanks again for your efforts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top