RE: [PHP] Dreaded Return-Path and mail()
Almost exactly the same question as the message with subject: Sendmail configuration The problem you are having took me a while to grasp. Basically, what happens is that sendmail sends the mail as the user php/apache was installed as (usually nobody@ or apache@ yourdomain.com). Setting the Return-Path does not work, as you cannot override the Return-Path set by the server in this way, that's why messages bounce to your root account when sent with a php mail() function. If you only host one domain on a server, you can fix this by editing the sendmail.cf file and setting the Return-Path: to something more meaningful: However, most people don't have the luxury of having a one domain hosting solution. Your only other option is to invoke sendmail with the -f switch: sendmail -f sender@address recipient@address file_containing_message This forces a from: address, but it also produces a warning to the recipient that the message headers might be forged, but return mails and replies are directed to the address specified. Only problem with all this is that you need to do one of 2 things: a) use of PHP's system commands eg. $mail = `echo -e Subject: Subject here\n\n Message here | /usr/sbin/sendmail -f $your_address $recipient_address`; OR b) use a PERL script to do it. I am currently looking at both, and it seems at this stage that the PERL script will be the better option, specially if you need to mail to alot of people. You need to issue the sendmail in a loop, and for load balancing, it's best to put a sleep() inside the loop; even if you only make this a sleep(1) (sleep for 1 sec), PHP will timeout after only 30 recipients unless you override the default timeout setting for php scripts. On Tue, 2003-01-07 at 02:37, Timothy Hitchens (HiTCHO) wrote: Hmm... I would expect that your sendmail.cf (if you are using sendmail) hasn't got your webserver (running as eg www or apache etc) in it's trusted users file / listing. HiTCHO has Spoken! Timothy Hitchens (HiTCHO) [EMAIL PROTECTED] -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 7 January 2003 10:34 AM To: PHP General list Cc: Monty Subject: Re: [PHP] Dreaded Return-Path and mail() Monty -- ...and then Monty said... % % Okay, I've read just about everything on the Internet about how the change % the Return-Path header in an e-mail sent using mail(), but, I STILL can't % get it to work. All e-mail sent via PHP says Return-Path: [EMAIL PROTECTED] % and Received: (from nobody@localhost). How interesting. What do you get if you put $to = [EMAIL PROTECTED] ; $subj = here is a subject ; $body = this is the message body ; $hdrs = From: [EMAIL PROTECTED]\r\nReturn-Path: [EMAIL PROTECTED] ; mail($to,$subj,$body,$hdrs) ; in a php script and execute it? If it doesn't work, what do the mail server lots on your web server say? I just tested this code on my box and it worked, so if you have problems then you can figure it's your mail setup and not your code. If it works, expand from there in small steps :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dreaded Return-Path and mail()
As I have said before that if you set the webserver user in as a trusted user in the sendmail.cf file all is fixed. You can then set a return-path etc without warnings as well. HiTCHO has Spoken! Timothy Hitchens (HiTCHO) [EMAIL PROTECTED] -Original Message- From: Petre Agenbag [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 7 January 2003 7:43 PM To: Timothy Hitchens (HiTCHO) Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Dreaded Return-Path and mail() Almost exactly the same question as the message with subject: Sendmail configuration The problem you are having took me a while to grasp. Basically, what happens is that sendmail sends the mail as the user php/apache was installed as (usually nobody@ or apache@ yourdomain.com). Setting the Return-Path does not work, as you cannot override the Return-Path set by the server in this way, that's why messages bounce to your root account when sent with a php mail() function. If you only host one domain on a server, you can fix this by editing the sendmail.cf file and setting the Return-Path: to something more meaningful: However, most people don't have the luxury of having a one domain hosting solution. Your only other option is to invoke sendmail with the -f switch: sendmail -f sender@address recipient@address file_containing_message This forces a from: address, but it also produces a warning to the recipient that the message headers might be forged, but return mails and replies are directed to the address specified. Only problem with all this is that you need to do one of 2 things: a) use of PHP's system commands eg. $mail = `echo -e Subject: Subject here\n\n Message here | /usr/sbin/sendmail -f $your_address $recipient_address`; OR b) use a PERL script to do it. I am currently looking at both, and it seems at this stage that the PERL script will be the better option, specially if you need to mail to alot of people. You need to issue the sendmail in a loop, and for load balancing, it's best to put a sleep() inside the loop; even if you only make this a sleep(1) (sleep for 1 sec), PHP will timeout after only 30 recipients unless you override the default timeout setting for php scripts. On Tue, 2003-01-07 at 02:37, Timothy Hitchens (HiTCHO) wrote: Hmm... I would expect that your sendmail.cf (if you are using sendmail) hasn't got your webserver (running as eg www or apache etc) in it's trusted users file / listing. HiTCHO has Spoken! Timothy Hitchens (HiTCHO) [EMAIL PROTECTED] -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 7 January 2003 10:34 AM To: PHP General list Cc: Monty Subject: Re: [PHP] Dreaded Return-Path and mail() Monty -- ...and then Monty said... % % Okay, I've read just about everything on the Internet about how the change % the Return-Path header in an e-mail sent using mail(), but, I STILL can't % get it to work. All e-mail sent via PHP says Return-Path: [EMAIL PROTECTED] % and Received: (from nobody@localhost). How interesting. What do you get if you put $to = [EMAIL PROTECTED] ; $subj = here is a subject ; $body = this is the message body ; $hdrs = From: [EMAIL PROTECTED]\r\nReturn-Path: [EMAIL PROTECTED] ; mail($to,$subj,$body,$hdrs) ; in a php script and execute it? If it doesn't work, what do the mail server lots on your web server say? I just tested this code on my box and it worked, so if you have problems then you can figure it's your mail setup and not your code. If it works, expand from there in small steps :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dreaded Return-Path and mail()
Okay, I've read just about everything on the Internet about how the change the Return-Path header in an e-mail sent using mail(), but, I STILL can't get it to work. All e-mail sent via PHP says Return-Path: [EMAIL PROTECTED] and Received: (from nobody@localhost). I have a Red Hat Linux 7.2 server running PHP 4.2.2. I've tried the following and none of them worked: + I put the following in my Apache httpd.conf file: php_admin_value sendmail_path /usr/bin/sendmail -t -i -f [EMAIL PROTECTED] I also tried this without -t and -i. None of them worked. I did remember to re-start Apache each time so the settings took effect. + I tried adding -f [EMAIL PROTECTED] as the fifth parameter for the mail() command, but, that didn't make a difference either. Actually, as I have other items for the fifth header parameter, I wasn't sure where the above command should be placed. I tried at the beginning and end of other header info I was placing, but, nothing seemed to work. + I added nobody to Sendmail's trusted users. No difference. Is there anything else I can try? I want to avoid changing this in the PHP.ini file because I don't want e-mail from all domains to look like it is coming from a single domain, if possible. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dreaded Return-Path and mail()
Monty -- ...and then Monty said... % % Okay, I've read just about everything on the Internet about how the change % the Return-Path header in an e-mail sent using mail(), but, I STILL can't % get it to work. All e-mail sent via PHP says Return-Path: [EMAIL PROTECTED] % and Received: (from nobody@localhost). How interesting. What do you get if you put $to = [EMAIL PROTECTED] ; $subj = here is a subject ; $body = this is the message body ; $hdrs = From: [EMAIL PROTECTED]\r\nReturn-Path: [EMAIL PROTECTED] ; mail($to,$subj,$body,$hdrs) ; in a php script and execute it? If it doesn't work, what do the mail server lots on your web server say? I just tested this code on my box and it worked, so if you have problems then you can figure it's your mail setup and not your code. If it works, expand from there in small steps :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg91859/pgp0.pgp Description: PGP signature
RE: [PHP] Dreaded Return-Path and mail()
Hmm... I would expect that your sendmail.cf (if you are using sendmail) hasn't got your webserver (running as eg www or apache etc) in it's trusted users file / listing. HiTCHO has Spoken! Timothy Hitchens (HiTCHO) [EMAIL PROTECTED] -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 7 January 2003 10:34 AM To: PHP General list Cc: Monty Subject: Re: [PHP] Dreaded Return-Path and mail() Monty -- ...and then Monty said... % % Okay, I've read just about everything on the Internet about how the change % the Return-Path header in an e-mail sent using mail(), but, I STILL can't % get it to work. All e-mail sent via PHP says Return-Path: [EMAIL PROTECTED] % and Received: (from nobody@localhost). How interesting. What do you get if you put $to = [EMAIL PROTECTED] ; $subj = here is a subject ; $body = this is the message body ; $hdrs = From: [EMAIL PROTECTED]\r\nReturn-Path: [EMAIL PROTECTED] ; mail($to,$subj,$body,$hdrs) ; in a php script and execute it? If it doesn't work, what do the mail server lots on your web server say? I just tested this code on my box and it worked, so if you have problems then you can figure it's your mail setup and not your code. If it works, expand from there in small steps :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php