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.

Bash script and mail command to hosted domain

Discussion in 'General Discussion' started by InteractM, Mar 17, 2016.

  1. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I have a bash script which sends a mail using mail system command. All works fine unless I will use an email address which website is hosted on the same server but mail server is the Office365. At that point mail tries to send it locally but there is no mailbox for that account on that server.

    Any clue how it can be resolved?

    Thanks
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,146
    Likes Received:
    34
    Trophy Points:
    48
    Location:
    India
    cPanel Access Level:
    Root Administrator
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, as mentioned, please ensure the "Email Routing" configuration for this domain name is set to "Remote Mail Exchanger".

    Thank you.
     
  4. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    But cron is running as root so it is still related to that particular domain?
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, no matter the sender, it's handled with Exim. Exim will automatically assume any domain name in the /etc/localdomains file is a local domain name, and thus attempt the local delivery. Thus, ensuring the "Email Routing" configuration for this domain name is set to "Remote Mail Exchanger" will place the domain name in the /etc/remotedomains file and let Exim know that email for this domain name is handled by a remote server.

    Thank you.
     
  6. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    OK - so is not working then as should. I have "Email Routing" set to external MX record and bash script do not deliver emails to that external email account. nslookup for shows proper record for MX.

    Any clue what is going on?
     
    #6 InteractM, Mar 24, 2016
    Last edited: Mar 24, 2016
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you verify the domain name you are sending to is in the /etc/remotedomains file and not the /etc/localdomains file? EX:

    Code:
    grep domain.com /etc/remotedomains
    Thank you.
     
  8. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Yes - is in the the /etc/remotedomains file and not the /etc/localdomains.
     
  9. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Also it looks like PHP is not sending emails to different cPanel account, which website is hosted on the same box, but MX record is set to the remote one.

    Any clue?

    Thanks
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
  11. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Support Request ID is: 7564727
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    It looks like the request was closed after inactivity. Were you able to address this issue?

    Thank you.
     
Loading...

Share This Page