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.

bounced emails going to nobody

Discussion in 'E-mail Discussions' started by ramorse, Nov 3, 2004.

  1. ramorse

    ramorse Well-Known Member

    Joined:
    Sep 6, 2003
    Messages:
    201
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    I have several accounts that we developed php scripts for that send out emails to people such as postcard scripts, or scripts that send out to a list of selected people. If the script sends out to a bad email address the bounce messages get sent to nobody which then get forwarded to me as server admin even though there is a specific user's email address in the from field in each message that goes out.

    I am assuming then, that the server is inserting the nobody address somewhere in the header of each email. Is there a configuration on the server that inserts the senders email in the right place in the header?
     
  2. dezignguy

    dezignguy Well-Known Member

    Joined:
    Sep 26, 2004
    Messages:
    534
    Likes Received:
    0
    Trophy Points:
    16
    It's the Return-path: in the header...
    Exim seems to have been changed by cpanel to no longer automatically figure out where these emails should really go.

    There are a number of other threads here discussing this... search for them for more info.
     
  3. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    I've been following this one up to.

    It appears you have to enable phpsuexec and rebuild apache, so the php scripts
    will run under the ID of the user and not nobody.
    Then you have to ensure the scripts are chmod'd like perl scripts to get them to
    work correctly.

    Did that, it caused a configuartion error apache page to appear, i think something
    needed updating in the httpd.conf file.

    So i recompiled without it.
    I thought, why go to all this trouble when it wasn't using phpsuexec in the first place
    and the return to path used to work.

    The odd thing is, if the mail address is correct, then the reply-to is the sender address
    of the mail and not nobody@mysubdomain.myserver.com
    It appears EXIM is adding the return-path nobody@mysubdomain.myserver.com
    so bounded e-mails from all the hosting accounts come bouncing back to the
    server admin acccount for php based apps, since they run as nobody.

    That was my question, without using phpsuexec, how can EXIM be changed to
    figure things out like it used to.

    On i plod!!!

    If you get an answer before i do, please update this thread.
     
  4. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    return-path nobody bounced mail in PHP - Solution

    Thanks to those members who have posted the solution,
    here is the implementation notes for those a little more challenged:

    Open "WHM"
    Under "Service Configuration" , click "Exim Configuration Editor"
    Click "Switch to advanced mode"

    In the first editable text box below
    #!!# cPanel Exim 4 Config:

    ADD:

    local_from_check = false
    untrusted_set_sender = root


    In the textbox that follows (REWRITE CONFIGURATION)
    begin rewrite:

    ADD:

    nobody@lsearch;/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
    cpanel@lsearch;/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs

    NOTE: there is no space between fai and l in the word fail above.
    There appears to be a text translation problem in the forum.


    Now Click Save, Exim will restart with the updated config.
    It now works ( it does for me ).
    One note worth mentioning, the TextBoxes were empty prior to
    me populating them.
     
    #4 neil_rutherford, Nov 5, 2004
    Last edited: Nov 7, 2004
    Metro2 and ccccanada like this.
  5. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    This method did not work for me. if someone has the solution please let me know. Thanks. :) I'm actually looking through this thread too. Not sure if it is the same problem.
     
    #5 lemonsensation, Nov 6, 2004
    Last edited: Nov 6, 2004
  6. FWC

    FWC Well-Known Member

    Joined:
    May 13, 2002
    Messages:
    354
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Ontario, Canada
    Remove the spaces between the i and l in the word fail in each line. That will break the rewrite and prevent it from doing it's job. It worked for me after I fixed them.
     
  7. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    It must be a forum problem.

    I copied the rewrite rule and it appears ok without the space between fai and l
    You view it and it appears with a space.
    You edit it the text to update it and no space.... must be text translation in the forum
    that is doing this.
     
  8. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    crap, actually my problem with PHP scripts is a little bit different than yours. My problem with PHP scripts is that when the php script tries to send out an email, it sends the email as "nobody@MYHOSTNAME.com" when the web address and MYHOSTNAME are totally different. So to solve this problem, I turn on "Prevent the user 'nobody' from sending out mail to remote addresses (php and cgi scripts generally run as nobody if you are not using phpsuexec and suexec respectively.)"

    After doing that, emails get stuck in the Mail Queue. It says the email it was trying to send to has an "unrouteable mail domain".

    I tried the PHPsuexec and it fixed the problem. However, I would like to keep phpsuexec off, if possible. So I try out this solution by modifying Exim. At first it didn't work at all because of the "fai l" problem. After fixing it, the email instead of going to the mail queue, it gets sent to :blackhole: with the same error saying "unrouteable mail domain".

    The php script I am using is Drupal. I'm using WHM 9.9.7 cPanel 9.9.8-S6. Basically, emails are being sent out as nobody even though I have configured Drupal. Works fine with phpsuexec but I would like to keep phpsuexec off.

    UPDATE: I made my own thread since my problem is different than yours. It is here: http://forums.cpanel.net/showthread.php?p=151092#post151092
     
    #8 lemonsensation, Nov 7, 2004
    Last edited: Nov 7, 2004
  9. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    PHP:
    actually my problem with PHP scripts is a little bit different than yoursMy problem with PHP scripts is that when the php script tries to send out an emailit sends the email as "nobody@MYHOSTNAME.com" when the web address and MYHOSTNAME are totally different.
    From what you are saying above, it's symptomatic of what i had.
    PHP was sending mail as nobody@.... because phpsuexec was off and apache uses nobody
    account.
    phpsuexec is still off, i applied what was written above and now all PHP mail
    sent via the PHP scripts i have written go via their account and host name and any
    are returned mails are returned to the account that sent them, not nobody.

    You might have other config parameters configured differently which is stopping you achieving your goal.
     
  10. ccccanada

    ccccanada Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    279
    Likes Received:
    0
    Trophy Points:
    16
    Hello Neil!

    The fix that you have posted in this thread worked great on all my servers.

    Mail is still being send by nobody@myserver.com but when there are any bouces it gets returned to the sender address.

    Thank you for posting it here I did a search for this a few times now but never found the fix anywhere else.
     
  11. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hi, Yah you are right neil_rutherford. ccccanada pointed it out in my other thread. I had
    enabled and phpsuexec disabled so it just wouldn't allow PHP to send emails at all even though I added your code. In order for you code to work, I need to keep "Prevent the user 'nobody' from sending out mail" OFF and phpsuexec OFF. Thanks. :)
     
  12. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    I'm using the following stable version:

    WHM 9.9.7 cPanel 9.9.8-R5
    RedHat Enterprise 3 i686 - WHM X v3.1.0

    Attached is a copy of the servers exim.conf that cpanel merges with the changes
    i've added via the cpanel admin tool.
    Compare it to see what is different with your settings.

    Or, upload it to your server, and copy it to
    /etc/exim.conf
    and restart exim.

    It sends e-mail as user@user.com and return path is user@user.com (for example).

    I've included a php test mailing script you can run.

    Don't forget to rename both files attached to
    exim.conf and email-test.php

    Update the from and to address in the top of the email-test.php

    Neil.
     

    Attached Files:

  13. speckados

    speckados Well-Known Member

    Joined:
    May 21, 2003
    Messages:
    291
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Acequias :: Granada :: España
    cPanel Access Level:
    DataCenter Provider
    Twitter:
  14. netlook

    netlook Well-Known Member
    PartnerNOC

    Joined:
    Mar 25, 2004
    Messages:
    335
    Likes Received:
    0
    Trophy Points:
    16
    It works great, but if there is no "From:" header, mails are bounced to root.
    So how to modify those lines to make such thing:

    bounced messages are delivered to sender (not nobody) and if there is no valid sender they are simply deleted and not send to root.

    Hope you will help me :eek:
     
  15. we_are_borg

    we_are_borg Member

    Joined:
    Mar 16, 2003
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    i'm gettin a error in the line below the other one is working as far as i can tell at the moment.

    But when i did this earlyer it was working but now it doesn't. Can some one advice me.

    Code:
    error in ACL: unknown ACL verb in "nobody@lsearch;/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs"
    
    The fail is not fai l but it reads fail
     
  16. ttremain

    ttremain Well-Known Member

    Joined:
    Feb 16, 2003
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Sounds like the scripts are using incomplete headers... Fix the scripts to append return headers in the mail() command.

    Code:
    
    //set the mail message up 
    $mailheaders="From: return@domain.com\r\n" .
         "Reply-To: return@domain.com\r\n" .
         "X-Mailer: PHP/" . phpversion();
    mail($to, $subject, $body, $mailheaders); 
    
    
    If the mail() command is formatted properly in PHP, the returns go to the right
    place, and you don't have to have phpsuexec.

    __________________
    Thomas Tremain
    LiveHost.net Web Hosting
    GotoNames.com Domain Name Registration
    TrafficExaminer.com web site stats for professionals
     
  17. ramorse

    ramorse Well-Known Member

    Joined:
    Sep 6, 2003
    Messages:
    201
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    I applied the Exim fix stated above and it worked beautifully! Thanks! Where do you get stuff like that?
     
  18. spaceman

    spaceman Well-Known Member

    Joined:
    Mar 25, 2002
    Messages:
    481
    Likes Received:
    0
    Trophy Points:
    16
    Much to my surprise, this worked for me without editing exim.conf (note the -f option in the 5th parameter $more). I'm running exim-4.52-7.

    PHP:

    <?php
    $to      
    "nonexistentperson@test.com";
    $from    "myaddress@mydomain.com";      
    $subject "the subject";
    $message "the message";
    $headers "From: $from";
    $more    "-f$from";

    mail($to$subject$message$headers$more);

    ?> 

     
  19. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Yes you can of course use the correct sendmail -f command at the fifth argument of the mail() function.

    But try getting all your hosting clients to edit their scripts like osCommerce and all the others that don't use the fifth argument of sendmail. It just doesn't happen.

    For hosting providers it must be tackled at the server end not the PHP files.

    Just my 2 cents.

    Thanks for the great thread.

    Aaron
     
  20. spaceman

    spaceman Well-Known Member

    Joined:
    Mar 25, 2002
    Messages:
    481
    Likes Received:
    0
    Trophy Points:
    16
    Absolutely right. The -f php mail solution only applies where the code is your own and/or you're prepared to hack/mod 3rd party software.
     
Loading...

Share This Page