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.

email to root@localhost gets routed/bounced incorrectly

Discussion in 'E-mail Discussions' started by aww, Dec 16, 2011.

  1. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Shouldn't I be able to send email to root@localhost in my (root) scripts on cpanel ?

    It gets bounced to root@localhost.hostdomainexample.com

    where extended.hostdomainexample.com is the full hostname (example)

    not sure why it thinks "localhost" is a subdomain of the hostname, very strange.

    Can I fix this behavior?
     
  2. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    In root WHM, go to:
    Server Contacts-> Change System Mail Preferences
    and set root's mail.
     
  3. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks but of course that was done a long time ago and was set properly. It's not the cause or fix.
     
  4. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    Yes, of course, and of course you have also checked what there is in /root/.forward
     
  5. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Yup, that file is there and correct. Open to other ideas, thanks.
    tell me if this test is valid? (example is of course replaced with the actual server domain)

    echo "test" | mail -s "test" root@localhost
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Can you please post the output of these commands?

    Code:
    cat /etc/localaliases
    cat /var/cpanel/userhomes/cpanel/.forward
    cat /root/.forward
    grep email@domain.com /etc/valiases/*
    grep email@domain.com /etc/vfilters/*
    Please replace email@domain.com for the above listed commands with the email address set in WHM > Change System Mail Preferences area.
     
  7. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks for your help Tristan

    (in these results I've replaced the server domain with example)

    cat /etc/localaliases
    cpanel: root
    root: server@example.com

    cat /var/cpanel/userhomes/cpanel/.forward
    root

    cat /root/.forward
    server@example.com

    grep server@example.com /etc/valiases/*
    (nothing)

    grep server@example.com /etc/vfilters/*
    (nothing)


    I kinda think I see where you are going with this - trying to see if the email is routed or bounced away.

    But isn't the real problem that root@localhost gets translated into root@localhost.example.com when it should not, it should just lookup the alias for root without trying to make it a subdomain?
     
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Part of the issue is that /etc/localaliases isn't set to server@example.com for cpanel, nobody and root. You can change that either directly in /etc/localaliases by setting it to show this instead:

    cpanel: server@example.com
    nobody: server@example.com
    root: server@example.com

    Or, it could be changed in WHM > Change System Mail Preferences area.

    Next, /var/cpanel/userhomes/cpanel/.forward file would need to be set to that email account as well:

    server@example.com

    When it is set as root, then root@localhost should translate to root@hostname because localhost is normally routed to the server's hostname. If the above steps are not fixing the issue, please open up a ticket at that point for us to further investigate.

    Also, if you could provide the output for these commands as I'd like to see the /etc/hosts entry for localhost as well as any possible mail_reverse_dns entries:

    Code:
    cat /etc/hosts
    cat /etc/mail_reverse_dns
     
  9. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Okay, I went back into Change System Mail Preferences area and made sure I re-did all three to server@example.com

    Then I double checked /var/cpanel/userhomes/cpanel/.forward and yes it also contains server@example.com

    Then this still fails (bounces exactly as posted above)
    echo "test" | mail -s "test" root@localhost


    cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost
    70.87.220.252 updates.cpanel.net
    70.87.220.252 httpupdate.cpanel.net
    70.87.220.252 layer2.cpanel.net
    2x.1xx.2xx.x server.example.com server

    cat /etc/mail_reverse_dns
    2x.1xx.2xx.x: server.example.com



    By the way, if it's not obvious root@server.example.com WORKS (because that's how I get the bounce emails)

    Also it occurs to me to mention at one point this server had it's host name renamed via whm
    (I am not sure if it ever worked before then, it was not really in use yet)
    I mention this because I see the old host name appended in /etc/hosts which I have now removed.

    OH! One more thought - we are not using named but nsd instead
    Really should not matter but just in case since that does the lookups for "localhost" yes?
     
    #9 aww, Dec 19, 2011
    Last edited: Dec 19, 2011
  10. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    You know what's interesting is I just went and tried the mail test on another cpanel server I operate and the mail doesn't even show up anywhere. It just vanishes.

    All the fowards and cpanel system settings are set properly. Mail to root@fullhostname.com does work.

    I think on this other server I use :blackhole: though
    - on the first one we are dealing with above, I use :fail:

    So perhaps this comes down to those rules, where root@localhost is simply not recognized as a valid mailbox?

    Have you actually tried the mail root@localhost on a stock cpanel box?

    I have one other cpanel server I can try this on but not until much later today.
     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    On a system where none of the mail settings have been configured, this is the response for routing:

    Code:
    exim -bt root@localhost
    root@localhost
      router = localuser, transport = local_delivery
    When sending a test email to root@localhost, it shows the following:

    I imagine this would make sense for the receiving email account because root is on the never user's list unless you configure the root emails to go to a working address in WHM > Change System Mail Preferences area.

    On my machine where I have abuse@maindomain.com set for all the preferences and where I also setup the abuse@maindomain.com account, it shows this for routing:

    Code:
    root@host [~]# exim -bt root@localhost
    abuse@maindomain.com
        <-- root@maindomain.com
        <-- abuse@maindomain.com
        <-- abuse@maindomain.com
        <-- root@localhost
      router = virtual_user, transport = virtual_userdelivery
    For emails sent to root@localhost, it returns the following on my machine:

    Would you be able to show the routing rules for root@localhost by running the command show below?

    Code:
    exim -bt root@localhost
     
  12. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    thanks for your patience with all this Tristian

    exim -bt root@localhost

    LOG: MAIN
    remote host address is the local host: localhost.example.com (while routing <root@localhost.example.com>)
    root@localhost.example.com cannot be resolved at this time: remote host address is the local host
    <-- root@localhost


    ...I just had a realization about something that may affect all this:

    while server.example.com is the hostname
    but note that example.com is also setup as an account on the server too (for management reasons, email, etc)

    I've never had a problem with that kind of configuration, but in this particular case of trying to use root@localhost, perhaps it is causing alias issues?
     
    #12 aww, Dec 19, 2011
    Last edited: Dec 19, 2011
  13. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    It's stating localhost.example.com is a remote address. Is example.com in /etc/remotedomains location? Please grep for example.com in /etc/remotedomains file:

    Code:
    grep example.com /etc/remotedomains
     
  14. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    My other server where the email just disappears without bounce - also does the same error with the exim trace

    And it also has the domain of the hostname added as an account.

    So I think I am onto something?
     
  15. aww

    aww Well-Known Member

    Joined:
    Feb 10, 2005
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    remotedomains consists of just one single line and it's another domain that is an account on the server

    ah that other account uses gmail for it's email routing but it has nothing to do with this problem


    wait are you saying it should have the hostname domain in remotedomains? that's interesting
     
  16. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Nope, the hostname wouldn't be in remotedomains. I'm trying to figure out why it is outputting the error for routing:

    It indicates it isn't a local address but a remote address for localhost.

    Could you submit a ticket for this one machine using WHM > Support Center > Contact cPanel or via the link in my signature. If you would be able to post the ticket number here for tracking purposes as well.
     
Loading...

Share This Page