Re: [PHP] PHP's mail(): proper way to send a 'From' header
You missed the period in your header to join the name and the line break?? 'From: [EMAIL PROTECTED]' . \r\n On 7/7/08, Jay Moore [EMAIL PROTECTED] wrote: Greetings folks. I seem to be having a problem with PHP's mail() function and sending 'From' headers properly. Here's my setup: I have a site I set up for a client that has a form their clients can fill out to submit some data. When the form is submitted, I have PHP gather the data and create the body of an email which is then sent to both the owners of the site and back to the person who submitted the data. Because the server hosts multiple sites, I am sending an additional 'From' header so the email doesn't appear to come from the hostname of the server itself ( [EMAIL PROTECTED]). Because I did not have a DNS entry for my hostname, the 'domain does not exist' error I'm seeing in the bounce emails is correct. I do not wish to keep a DNS entry for it (I have added one as a temporary fix), as that doesn't fix the 'From' header issue to begin with, so I would appreciate it if you did not make that suggestion. As per PHP's documentation of the mail() function, I am sending the header like so: From: [EMAIL PROTECTED] I am getting bounce emails from certain ISPs (AOL, Roadrunner, some local ISPs) saying the sender's domain does not exist. It seems that either mails are coming from my hostname ([EMAIL PROTECTED]), or those ISPs are reading the additional headers incorrectly. Unfortunately, this is not acceptable. People aren't getting their emails, and the hammer is coming down on me. As far as I know (based on the lack of bounce emails), this worked fine on PHP4, but with our new webserver (running PHP5), I'm experiencing problems. Far as I can tell, the mail() function has not changed between versions. I'm stumped here and need to get this fixed asap. I've tried 'From' and 'FROM', tried a 'Name Here [EMAIL PROTECTED]' format, and tried terminating with double newlines with and without the carriage return. Nothing seems to work. I've even gone so far as to edit php.ini with a default from address, but that doesn't appear to have fixed anything either. Please help. Thanks in advance, Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On Mon, Jul 7, 2008 at 2:06 PM, Dan Shirah [EMAIL PROTECTED] wrote: You missed the period in your header to join the name and the line break?? That's not required, since the OP is using double quotes (translation will occur). -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On Mon, Jul 7, 2008 at 2:06 PM, Dan Shirah [EMAIL PROTECTED] wrote: You missed the period in your header to join the name and the line break?? 'From: [EMAIL PROTECTED]' . \r\n On 7/7/08, Jay Moore [EMAIL PROTECTED] wrote: Greetings folks. I seem to be having a problem with PHP's mail() function and sending 'From' headers properly. Here's my setup: I have a site I set up for a client that has a form their clients can fill out to submit some data. When the form is submitted, I have PHP gather the data and create the body of an email which is then sent to both the owners of the site and back to the person who submitted the data. Because the server hosts multiple sites, I am sending an additional 'From' header so the email doesn't appear to come from the hostname of the server itself ( [EMAIL PROTECTED]). Because I did not have a DNS entry for my hostname, the 'domain does not exist' error I'm seeing in the bounce emails is correct. I do not wish to keep a DNS entry for it (I have added one as a temporary fix), as that doesn't fix the 'From' header issue to begin with, so I would appreciate it if you did not make that suggestion. As per PHP's documentation of the mail() function, I am sending the header like so: From: [EMAIL PROTECTED] I am getting bounce emails from certain ISPs (AOL, Roadrunner, some local ISPs) saying the sender's domain does not exist. It seems that either mails are coming from my hostname ([EMAIL PROTECTED]), or those ISPs are reading the additional headers incorrectly. Unfortunately, this is not acceptable. People aren't getting their emails, and the hammer is coming down on me. As far as I know (based on the lack of bounce emails), this worked fine on PHP4, but with our new webserver (running PHP5), I'm experiencing problems. Far as I can tell, the mail() function has not changed between versions. I'm stumped here and need to get this fixed asap. I've tried 'From' and 'FROM', tried a 'Name Here [EMAIL PROTECTED]' format, and tried terminating with double newlines with and without the carriage return. Nothing seems to work. I've even gone so far as to edit php.ini with a default from address, but that doesn't appear to have fixed anything either. Please help. Thanks in advance, Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Dan, His example would have worked since it was the entire thing surrounded in quotes. Jay, Perhaps you can use the additional parameters to -f a return path along with your header. Whatever your current scripts domain is can be set as the [EMAIL PROTECTED] as long as you control the domain (see SPF rules). Maybe this will fix your issues? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On Mon, Jul 7, 2008 at 1:50 PM, Jay Moore [EMAIL PROTECTED] wrote: Greetings folks. I seem to be having a problem with PHP's mail() function and sending 'From' headers properly. Here's my setup: [snip!] I am getting bounce emails from certain ISPs (AOL, Roadrunner, some local ISPs) saying the sender's domain does not exist. It seems that either mails are coming from my hostname ([EMAIL PROTECTED]), or those ISPs are reading the additional headers incorrectly. Unfortunately, this is not acceptable. People aren't getting their emails, and the hammer is coming down on me. Jay, try something like this: ?php $to = [EMAIL PROTECTED]; $from = [EMAIL PROTECTED]; $subject = This is a test!; $body = \tThis is a test email.\n; $body .= That is all.; $headers = From: .$from.\r\n; $headers .= Reply-To: .$from.\r\n; $headers .= X-Mailer: .basename(__FILE__).-PHP/.phpversion().\r\n; $headers .= Return-Path: .$from.\r\n; mail($to,$subject,$body,$headers,'-f'.$from); ? Note the fifth parameter passed to mail(): http://php.net/mail -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On Mon, Jul 7, 2008 at 2:13 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Mon, Jul 7, 2008 at 1:50 PM, Jay Moore [EMAIL PROTECTED] wrote: Greetings folks. I seem to be having a problem with PHP's mail() function and sending 'From' headers properly. Here's my setup: [snip!] I am getting bounce emails from certain ISPs (AOL, Roadrunner, some local ISPs) saying the sender's domain does not exist. It seems that either mails are coming from my hostname ([EMAIL PROTECTED]), or those ISPs are reading the additional headers incorrectly. Unfortunately, this is not acceptable. People aren't getting their emails, and the hammer is coming down on me. Jay, try something like this: ?php $to = [EMAIL PROTECTED]; $from = [EMAIL PROTECTED]; $subject = This is a test!; $body = \tThis is a test email.\n; $body .= That is all.; $headers = From: .$from.\r\n; $headers .= Reply-To: .$from.\r\n; $headers .= X-Mailer: .basename(__FILE__).-PHP/.phpversion().\r\n; $headers .= Return-Path: .$from.\r\n; mail($to,$subject,$body,$headers,'-f'.$from); ? Note the fifth parameter passed to mail(): http://php.net/mail -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yep! Just a note on this though. You have to control the domain you're forcing the return-path on or else it will get rejected by a lot of servers because of SPF rules. It has bit my company in the behind quite a bit recently. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On Mon, Jul 7, 2008 at 2:17 PM, Eric Butera [EMAIL PROTECTED] wrote: Yep! Just a note on this though. You have to control the domain you're forcing the return-path on or else it will get rejected by a lot of servers because of SPF rules. It has bit my company in the behind quite a bit recently. :) Thanks for adding that, Eric. I had forgotten to mention it. :-) And I've run into the same problems, especially in the last year or so. It was because of an inter-domain contact form, similar to email, that allowed users to mail each other online without giving out an actual email address. The forced FROM caused a lot of problems, which could only be fixed by making permanent changes to the DNS --- which the OP doesn't want to do in this case. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
On 7 Jul 2008, at 18:50, Jay Moore wrote: Greetings folks. I seem to be having a problem with PHP's mail() function and sending 'From' headers properly. Here's my setup: I have a site I set up for a client that has a form their clients can fill out to submit some data. When the form is submitted, I have PHP gather the data and create the body of an email which is then sent to both the owners of the site and back to the person who submitted the data. Because the server hosts multiple sites, I am sending an additional 'From' header so the email doesn't appear to come from the hostname of the server itself ([EMAIL PROTECTED]). Because I did not have a DNS entry for my hostname, the 'domain does not exist' error I'm seeing in the bounce emails is correct. I do not wish to keep a DNS entry for it (I have added one as a temporary fix), as that doesn't fix the 'From' header issue to begin with, so I would appreciate it if you did not make that suggestion. As per PHP's documentation of the mail() function, I am sending the header like so: From: [EMAIL PROTECTED] I am getting bounce emails from certain ISPs (AOL, Roadrunner, some local ISPs) saying the sender's domain does not exist. It seems that either mails are coming from my hostname ([EMAIL PROTECTED]), or those ISPs are reading the additional headers incorrectly. Unfortunately, this is not acceptable. People aren't getting their emails, and the hammer is coming down on me. As far as I know (based on the lack of bounce emails), this worked fine on PHP4, but with our new webserver (running PHP5), I'm experiencing problems. Far as I can tell, the mail() function has not changed between versions. I'm stumped here and need to get this fixed asap. I've tried 'From' and 'FROM', tried a 'Name Here [EMAIL PROTECTED]' format, and tried terminating with double newlines with and without the carriage return. Nothing seems to work. I've even gone so far as to edit php.ini with a default from address, but that doesn't appear to have fixed anything either. The ISPs are likely looking at the envelope sender rather than the sender specified in the headers. If you're on a box using sendmail (which I think you are based on what you've said) you can set this using the 5th parameter to mail set to - f followed by the email address you want to use. i.e. '[EMAIL PROTECTED]' I believe this is covered on the manual page for the mail function. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
?php $to = [EMAIL PROTECTED]; $from = [EMAIL PROTECTED]; $subject = This is a test!; $body = \tThis is a test email.\n; $body .= That is all.; $headers = From: .$from.\r\n; $headers .= Reply-To: .$from.\r\n; $headers .= X-Mailer: .basename(__FILE__).-PHP/.phpversion().\r\n; $headers .= Return-Path: .$from.\r\n; mail($to,$subject,$body,$headers,'-f'.$from); ? Note the fifth parameter passed to mail(): http://php.net/mail And also note that the 5th parameter is an email address only.. Don't do something like: ?php $from = Me [EMAIL PROTECTED]; and try to use that as the 5th parameter, it won't work. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php