Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Question How do I set Return-Path for sendmail?

    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?

  2. #2
    ujr
    ujr is offline
    Member
    Join Date
    Mar 2004
    Posts
    294

    Default

    use the sendmail with -f or use something like:

    mail("to@domain.com", "subject", "message", "From: me@domain.com", "-fme@domain.com");

    the last (5th) parameter "-fme@domain.com" is the return address

  3. #3
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Oct 2003
    Posts
    1,931

    Default

    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 Code:
    nobody@lsearch;/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}Fs 
    I think thats all you need to do
    Lowest Host/Empire Technology LLC
    Affordable hosting solutions http://empire-hosting.net
    List Your hosting site FREE in http://hostgeneration.com

  4. #4
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Default

    @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?

  5. #5
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Oct 2003
    Posts
    1,931

    Default

    yes when a php script sends mail as nobody exim rewrites the mail header thats it
    Lowest Host/Empire Technology LLC
    Affordable hosting solutions http://empire-hosting.net
    List Your hosting site FREE in http://hostgeneration.com

  6. #6
    ujr
    ujr is offline
    Member
    Join Date
    Mar 2004
    Posts
    294

    Default

    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.

  7. #7
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Default

    Quote Originally Posted by ujr View Post
    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?

  8. #8
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Default

    Quote Originally Posted by dalem View Post
    yes when a php script sends mail as nobody exim rewrites the mail header thats it
    Actually, what I wanted was a line by line explanation of the code

    Have added to my mail server, can give it a test.

  9. #9
    ujr
    ujr is offline
    Member
    Join Date
    Mar 2004
    Posts
    294

    Default

    Quote Originally Posted by ajaydsouza View Post
    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.

  10. #10
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Default

    Quote Originally Posted by ujr View Post
    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 ??

  11. #11
    ujr
    ujr is offline
    Member
    Join Date
    Mar 2004
    Posts
    294

    Default

    >>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.

  12. #12
    Member ajaydsouza's Avatar
    Join Date
    Apr 2006
    Posts
    35

    Default

    Quote Originally Posted by ujr View Post
    >>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.
    hmm.... am going to have to learn Exim Rewrite rules

  13. #13
    ujr
    ujr is offline
    Member
    Join Date
    Mar 2004
    Posts
    294

    Default

    You'll find that what dalem posted above will work 99% of the time.

Similar Threads & Tags
Similar threads

  1. How do I set the Return-Path, etc mail headers via PHP?
    By simpleupdates in forum E-mail Discussions
    Replies: 2
    Last Post: 06-18-2008, 03:01 PM
  2. Set redirect and return to orignal path.
    By Pashio in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 06-14-2006, 11:27 AM
  3. sendmail return error in Horde
    By Juanra in forum cPanel and WHM Discussions
    Replies: 8
    Last Post: 09-10-2004, 08:49 AM
  4. Return Path
    By silvernetuk in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 11-21-2003, 05:20 AM
  5. Email Return-Path, return-path problems with email address
    By silvernetuk in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-21-2003, 05:29 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube