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.

Want to Route Bounced Mail to Proper Sender

Discussion in 'E-mail Discussions' started by urantian, Mar 21, 2005.

  1. urantian

    urantian Well-Known Member

    Joined:
    Jan 26, 2005
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Fayetteville, Arkansas
    cPanel Access Level:
    Root Administrator
    I want to route bounced mail back to the correct sender on my server. The mail being bounced is generated by CGI scripts, in reponse to visitors who fail to use a valid email address in shopping carts and contact forms.

    According to WHM, the Nobody@<hostname> address is used as the return route, if the CGI script is used without SUExec. And, that is my situation. Because I am using common scripting libraries and thousands of data files across reseller accounts, I found that I needed to disable SUExec, to get around a lot of permissions problems.

    As a result, my default email account is receiving all of the bounced CGI messages. Is there a way to properly route these? I am wondering whether I need a cron job to scan the messages and route them. Is there a better way?

    ---Michael
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Disabling SUEXEC is a very bad idea indeed as you open yourself up to server-wide exploits instead of being (mostly) restricted to one account. The other problem is the one that you have found, because scripts are sent from the user running them, they will be from nobody@hostname.

    You can get around that by using the -f qualifier with the return email address when you invoke sendmail in your scripts.
     
  3. urantian

    urantian Well-Known Member

    Joined:
    Jan 26, 2005
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Fayetteville, Arkansas
    cPanel Access Level:
    Root Administrator
    Did Not Work

    Hi Jonathan,

    Thank you very much for writing. I use a Perl variable to reference the sendmail program, and I set it like this:

    $mailprog = '/usr/sbin/sendmail -i -t -f' . $bounce_to;

    Where: $bounce_to is the email address of where to send bounced messages.

    However, the bounced messages are still being routed to Nobody@HostName. I tried putting a space after '-f' with no difference. According to the sendmail manual I found, there should be no space.

    ---

    As for SUEXEC, I agree that's not a good idea. However, it would be a maintenance nightmare to have redundant scripts and data files on several reseller accounts. One thing I may try is to use a single wrapper-like script for each reseller, that would use an argument to include and execute the intended common script stored elsewhere on the server. In theory, that should permit SUEXEC to be enabled while still maintaining a single source of script and data files.

    Thanks again for writing!

    ---Michael
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Hi Michael,

    When I invoke sendmail with our scripts I use the equivalent of:

    $mailprog = '/usr/sbin/sendmail -t -f ' . $bounce_to;

    You should also double check the code where $mailprog is actually used to make sure that it isn't adding anything more to it.
     
  5. rs-freddo

    rs-freddo Well-Known Member

    Joined:
    May 13, 2003
    Messages:
    832
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Australia
    cPanel Access Level:
    Root Administrator
    You also need to be a trusted account to change the -f qualifier. Generally this is only root. The exim manual should have something on making "nobody" trusted to change the -f. Although on a shared hosting server you are just asking for trouble....
     
  6. neo4242002

    neo4242002 Well-Known Member

    Joined:
    Jun 28, 2005
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    16
    How do I put a return email address with -f in PHP scripts?

    here is the mail() I am using in my scripts

    HTML:
    mail($to_email, $subject, $message, $headers);
     
  7. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    try something like
    Code:
    mail($to, $subject, $message, $headers, "-f$sender")
     
Loading...

Share This Page