Forum Moderators: coopster

Message Too Old, No Replies

mail() bounces to server address instead of From address

         

erikcw

4:32 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



Hi,

All email sent from php mail() that bounces is being returned to my servers admin email address instead of the "From" or "reply-to" address.

What needs to be put in my header code to ensure that this does not happen?


/* To send HTML mail, you can set the Content-type header. */
$from = "From: Name <info@domain.com>\n";
$from .= "X-Sender: info@domain.com\n";
$from .= "X-Mailer: PHP\n";
$from .= "X-Priority: 3\n";
$from .= "Return-Path: Name <info@domain.om>\n";
$from .= "Reply-To: Name <info@domain.com>\n";
$from .= "Content-type: text/html\n";

/* and now mail it */
mail($to, $subject, $message, $from);

jatar_k

4:34 pm on Jun 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what OS is the server?

you also have a typo in your Return-Path

erikcw

4:49 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



It's a linux box - mail is being bounced to the cpanel default admin address.

For return path - do you meen the domain part? domain.com...?

jatar_k

4:56 pm on Jun 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Return-Path: Name <info@domain.om>\n

I assume it is not like that in the real script just thought I would mention it

I set
Reply-To
Return-Path
From

all to the same address and it works

test it to one of your own accounts and look at the headers on the email and see what's there, it is often the order of the headers that can change things

py9jmas

5:27 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



SMTP servers bounce emails to the from address specified in the SMTP envelope. They don't care what's in the headers of the email itself.

I'm not much of a PHP person but look at this:

The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

[uk.php.net...]

hakre

6:49 pm on Jun 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



py9jmas is right / points into the right direction. this changed around the last year and more and more smtp servers (it's the programm that is sending the mail out) need the -f parameter to work properly. the actual php installation on debian for example and many others.

anshul

7:30 am on Jun 25, 2005 (gmt 0)

10+ Year Member



On Windows,
I've seen such error solved by,
ini_set(sendmail_from, $sender_email);
( I use this line always )
headers go as usual.