Settings bounceback address for the mail() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Settings bounceback address for the mail() function

Post by impulse() »

At the moment I have a script which e-mails several people. But if any of the addresses are undeliverable they bounce back to the server admin address. It was suggested that I set a "Reply-To" header, which I have, but the bouncebacks are still being sent to the server admin.

This is my header setup at the moment:

Code: Select all

$eol = "\r\n";

$headers .= "From: Calendar <noreply@mydomain.com.com>".$eol;
$headers .= "Reply-To: Calendar <noreply@mydomain.com.com>".$eol;
$headers .= "Return-Path: Calendar <noreply@mydomain.com.com>".$eol;
$headers .= "Message-ID: <".$now."noreply@mydomain.com.com>".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
noreply@mydomain.com is a valid e-mail address which I pickup, but nothing is being sent to there.

Any suggestions as to where I'm going wrong?

Regards,
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Settings bounceback address for the mail() function

Post by volka »

impulse() wrote:It was suggested that I set a "Reply-To" header, which I have, but the bouncebacks are still being sent to the server admin.
That's strange. What server is it?
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

FreeBSD 6.1-RELEASE FreeBSD 6.1-RELEASE #0:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Do you test the behaviour for sender and receiver on the same mail-server? i.e. you send from mydomain.com.com to mydomain.com.com and the mail should be bounced back to mydomain.com.com?
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

No. The server the PHP script and the sendmail server are on are different to the server that receives the e-mails.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I call mail 3 seperate times. The headers variable is always specified last in the arguments for the function and there are 4 arguments in total for the function that I have specified.

1. Sender address
2. Subject
3. Message
4. Headers

Does that all seem correct?
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I think I've found the problem but not the solution.

I've just looked at the headers for the e-mails I have received and they contain this line:

"Return-Path: <www@myServerDomain.com>"

Although this line is specified within the headers of my PHP file:

Code: Select all

$headers .= "Return-Path: Entanet Calendar <noreply@entagroup.com>".$eol;
:?:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Take a look at rfc822. If memory serves there's something about return-path and the last relay.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I think it's a Senmail configuration problem. Just had a look through Google and found this:

http://www.unitedforums.co.uk/vb/archiv ... t-787.html

I think Sendmail is overriding the Return-Path header.

Fix is to use "-f<returnaddress>" as the fifth argument in the mail() function.
Post Reply