How do I set Return-Path for sendmail?

ajaydsouza

Active Member
Apr 14, 2006
34
0
231
Hi,

Currently any mails that are being sent out by PHP have the Return-Path set to nobody

As a result any bounce notes are landing up at nobody which forwards to my server email address.

How do I ensure that the bounced emails actually land up to the from or some other email?
 

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,977
152
368
SLC
cPanel Access Level
DataCenter Provider
I think ajaydsouza wants do do it server wide not edit each script one at a time :)
there was a how too somwhere on the forums but I could not find it

open exim editor avanced editor and add this code to the REWRITE CONFIGURATION box
(6th box down)

PHP:
[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
I think thats all you need to do
 

ajaydsouza

Active Member
Apr 14, 2006
34
0
231
@ujr, Thanks. I was aware of the fifth parameter, but didn't want to use it because I can't ask everybody with me to use the same :(

@dalem, can you explain to me how exactly the code you gave me works?
 

ujr

Well-Known Member
Mar 19, 2004
290
0
166
what dalem suggested works server wide. That's what you wanted.

As long as there is a FROM address, it will re-write it properly.
 

ajaydsouza

Active Member
Apr 14, 2006
34
0
231
what dalem suggested works server wide. That's what you wanted.

As long as there is a FROM address, it will re-write it properly.
That is good, it replaces the Return-Path to the same as From correct?

In case the script doesn't set a From?
 

ujr

Well-Known Member
Mar 19, 2004
290
0
166
That is good, it replaces the Return-Path to the same as From correct?

In case the script doesn't set a From?
no, the line {$header_From:}{}{$header_sender:$header_From:}

will only match the FROM.

If you wanted to match the reply to you'd have to expand on it, and first check if the from is set, then test to see if a reply-to header was set.
 

ajaydsouza

Active Member
Apr 14, 2006
34
0
231
no, the line {$header_From:}{}{$header_sender:$header_From:}

will only match the FROM.

If you wanted to match the reply to you'd have to expand on it, and first check if the from is set, then test to see if a reply-to header was set.
I realized that this is needed. I got one such email from PHP where the from wasn't set but the reply-to was.

Do you know the code for checking for Reply-To first and then From ??
 

ujr

Well-Known Member
Mar 19, 2004
290
0
166
>>Do you know the code for checking for Reply-To first and then From

You'd want to check the from first, and use that as your sender...not the other way around.
 

ujr

Well-Known Member
Mar 19, 2004
290
0
166
You'll find that what dalem posted above will work 99% of the time.