The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I set Return-Path for sendmail?

Discussion in 'E-mail Discussions' started by ajaydsouza, Oct 26, 2006.

  1. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    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. ujr

    ujr Well-Known Member

    Joined:
    Mar 19, 2004
    Messages:
    290
    Likes Received:
    0
    Trophy Points:
    16
    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. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    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:
    nobody@lsearch;/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}Fs
    I think thats all you need to do
     
  4. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    @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. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    yes when a php script sends mail as nobody exim rewrites the mail header thats it
     
  6. ujr

    ujr Well-Known Member

    Joined:
    Mar 19, 2004
    Messages:
    290
    Likes Received:
    0
    Trophy Points:
    16
    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. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    That is good, it replaces the Return-Path to the same as From correct?

    In case the script doesn't set a From?
     
  8. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    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. ujr

    ujr Well-Known Member

    Joined:
    Mar 19, 2004
    Messages:
    290
    Likes Received:
    0
    Trophy Points:
    16
    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. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    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. ujr

    ujr Well-Known Member

    Joined:
    Mar 19, 2004
    Messages:
    290
    Likes Received:
    0
    Trophy Points:
    16
    >>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. ajaydsouza

    ajaydsouza Active Member

    Joined:
    Apr 14, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    hmm.... am going to have to learn Exim Rewrite rules :)
     
  13. ujr

    ujr Well-Known Member

    Joined:
    Mar 19, 2004
    Messages:
    290
    Likes Received:
    0
    Trophy Points:
    16
    You'll find that what dalem posted above will work 99% of the time.
     
Loading...

Share This Page