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.

Problem testing cron for email output

Discussion in 'E-mail Discussions' started by magicalwonders, Sep 10, 2014.

  1. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Hello,

    I've migrated to a new server which is running the same version of WHM, (CENTOS 6.5 x86_64 virtuozzo – webhost1 WHM 11.44.1 (build 18)) but after a week of tweaking by my tech support to get SPF and DKIM working, I am no longer getting emails sent by a script that is run by a cron job!

    The script still runs fine on the other VPS, so I'm fairly confident that it is not an issue with the script.

    I've tried to test the mail in conjunction with running a cron, but when following a tutorial, I seem to be falling at the first hurdle! :(

    I've created this simple script using nano via SSH -
    Code:
    <?php mail('myles@mydomain.com','Cron Job Test Script',phpversion()); ?> 
    I've then tested the script from the command line before setting up a cron, using - php cronTest.php However, no emails are produced! :(

    I've attached a couple of screenshots showing my efforts with nano. On checking I can see that the file is saved to the root.

    I can't see where I'm going wrong? Can anyone throw any light on this?

    Many thanks,

    Myles
     

    Attached Files:

  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    Have you tried using an alternative PHP mailer script just to rule out any issues with the existing script you are using? There are several PHP test scripts used for mailing that you can find on a search engine.

    Thank you.
     
  3. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I'm pretty sure that this is not a problem with the script itself. I tried installing the script on another domain on the server but I'm getting an Internal Server error returned.

    I've also noticed that all my wordpress sites have not been emailing any backups since migrating to new VPS. I had this problem once before on the old VPS, and it was something to do with a php setting on the server?

    I've looked in the error logs and there are a few that might be relevant ?

    Extract from suexec log
    The last four errors refer to my attempt to install the script that has stopped sending reports by email. It looks like some sort of permissions issue?

    Edit. It looks like my Wordpress sites are sending backups on other the cPanels on my VPS. I'm pretty sure they are failing on my account though. I'll know for sure by tomorrow as the next one is due tonight!
     
    #3 magicalwonders, Sep 11, 2014
    Last edited: Sep 11, 2014
  4. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I would like to test if php is able to send mail properly, and have found the following info. But am not 100% sure on where to upload the script? -

    Do I upload the testmail.php file to root of my server? Then just enter php -f testmail.php on the command line? have I understood this correctly??

    EDIT. I can see that this is really the same script that I have already used! If I specify my primary address, nothing comes through! If I use an address on the server, the message makes it into the mailbox but does not get forwarded.

    I've tested the same script on my other VPS and that successfully sends mail to my primary.
    Not sure how to proceed. It feels like I'm doing all the work that my host should be doing!
     
    #4 magicalwonders, Sep 12, 2014
    Last edited: Sep 12, 2014
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Have you checked to see if you are using the same PHP handler, as configured in "WHM Home » Service Configuration » Configure PHP and suEXEC"?

    Thank you.
     
  6. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Funny enough, my support asked the same question a couple of hours ago! I wasn't really sure how to find out the info as they didn't give the location like you have. I've supplied them with my old VPS login credentials so they can check.

    This problem coincides with a ticket they were working on to authenticate SPF and DKIM records. I don't know all the changes they made in that regard, but they did notify me of the following -

    That seemed to fix the SPF and DKIM, but I'm wondering if it could have messed up the Mail at the same time?
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    It seems more likely to be an issue with PHP sending out the email if you do not see any entries in /var/log/exim_mainlog for the messages you are sending.

    Thank you.
     
  8. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    OK I'll try and check those logs.

    I've managed to compare the configuration of php and suEXEC on the servers, and they are a bit different!

    The old VPS shows this as current configuration

    And the new one as follows -

    I'm not sure what the consequences of this difference is.
     
  9. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I've had a look in the exim logs and there is definitely a problem with my mail configuration.

    The reject log shows the following error in respect of the mail sent by my autoresponder script - I've changed the actual email address for this post so it doesn't get harvested.

    Code:
    2014-09-14 07:54:01 H=ns2.domain.com (webhost1.domain.com) [138.128.xxx.xx]:49233 rejected MAIL <arplus@mydomain.com>: "REJECTED - Bad HELO - Host impersonating [webhost1.domain.com]"
    2014-09-14 07:54:02 H=ns2.domain.com (webhost1.domain.com) [138.128.xxx.xx]:53206 rejected MAIL <>: "REJECTED - Bad HELO - Host impersonating [webhost1.domain.com]"
    
    The above domain is on a dedicated IP address, but no reverese DNS has been setup yet.

    I've looked at the email for the other accounts which are on a shared IP and they are having problems too! I tried sending mail to one of my domains and it shows the following in the Exim reject log -

    Code:
    2014-09-14 09:02:43 H=avasout02.otherdomain.net [212.159.xx.xx]:50969 F=<myles@mydomain.plus.com> temporarily rejected RCPT <info@mydomain.com>: lowest numbered MX record points to local host
    2014-09-14 09:02:44 H=avasout02.otherdomain.net [212.159.xx.xx]:50969 F=<myles@mydomain.otherdomain.com> temporarily rejected RCPT <info@mydomain.com>: lowest numbered MX record points to local host
    From what I can see, mail to all the other addresses in the accounts are showing the same error.

    Any ideas on what's gone wrong and how to fix this would be appreciated! :)
     
    #9 magicalwonders, Sep 14, 2014
    Last edited by a moderator: Sep 15, 2014
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You should configure "Apache suEXEC" to "ON" to match your source server if you prefer the same setup.

    Make sure the domain name is in your /etc/localdomains file if it's email is handled locally.

    Thank you.
     
  11. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Thank you Michael,

    I'll turn "Apache suEXEC" to "ON" as suggested.

    I've looked in the /etc/localdomains file as they mentioned today that one of the domains was missing. I can see that another domain is also missing, and none of the addon domains in the accounts are listed. Should addon domains be in this file? At the top of this file it has - server.yourdomain.com That doesn't sound right? Shouldn't there be a domain name after server.?


    I've also asked my host to setup reverse DNS for my domain on the dedicated IP. This is the setup I had on my other VPS and it all seemed to work OK. They've responded with the following question -

    I'm not sure where to find this information?

    Hope you can advise.

    Many thanks,

    Myles
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    1. Yes, it's normal to see your hostname in this file. Browse to "WHM Home » DNS Functions » Edit DNS Zone" and for each domain name that's missing set the "Email Routing" to:

    "Local Mail Exchanger"

    2. You can provide them with the hostname of your server, as it's generally recommended that you use it in the PTR record for your IP addresses.

    Thank you.
     
  13. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Thanks Michael,

    I've updated my host, and requested the relevant changes. I'll take a look tomorow and hopefully they'll have made some progress. :)
     
  14. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I can't see that my host has made any changes or progress, so I'm going to try and make the necessary changes myself.

    I'll try and fix one domain at a time, starting with my site that's on a dedicated IP address.

    I've attached the output from the error log for the last email triggered by my cron - Views best in Notepad++


    I've had a look in the "Edit DNS zone" and the entries don't look quite right to me, so maybe this is the cause of my woes for this domain. Screenshot included.

    DNS-Zone.jpg

    The IP address for this domain is assigned to NS2 in my private nameservers with the domain registrar. However, the nameserver for NS1 which is the shared IP has been used twice in the server configuration. That doesn't feel right to me?

    Also, I'm not sure if the third column at the top where is says - "youremailid.domain.com." needs and entry?

    Am I on the right track regarding the use of NS1 in the above setup?

    Many thanks,

    Myles
     

    Attached Files:

  15. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    The issue with the domain name's existence in the /etc/remotedomains file instead of the /etc/localdomains file is the primary cause of this problem as I see it. Please ensure you correct that before proceeding to troubleshoot further. I don't see any problems with the DNS configuration.

    Thank you.
     
  16. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Thanks for the help Michael,

    I've made some progress now. Mail to all the boxes on the shared IP now seem to be working OK.

    I did some further tests on the problem of getting system and scripts mail delivered to my magicalwonders domain on the dedicated IP. It looks like my IPS has been blocking them. I have removed the spam filter from my ISP mailbox and I'm now getting system messages from the server.

    It looks like a mistake was made when setting up rDNS, so I'm hoping when that resolves, the mail generated from scripts will then get through.

    The domain names now all seem to be present in the /etc/localdomains file, however the top entry is still showing as server.yourdomain.com Is this file edited directly, or do I need to enter correct info somewhere else?

    [Removed - Actual Domain Nmaes]

    The remote domains file has a slightly different looking list -

    [Removed - Actual Domain Nmaes]

    I'm not sure what is supposed to be on this list? It seems to be missing names that are on the local domain file. Again, is it edited directly if needed?

    Many thanks,

    Myles
     
  17. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    It's normal to see the hostname at the top of that file. It's supposed to be there. You can automatically populate those files with this command:

    Code:
    /usr/local/cpanel/scripts/checkalldomainsmxs
    However, ensure you manually add the hostname to the top of /etc/localdomains after you run the above command.

    Thank you.
     
  18. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Thanks Michael,

    Is it OK to just download the localdomains file, edit it, and then re-upload it? Or do I have to edit the fille via SSH in something like Nano?
     
  19. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Edit it via SSH with "nano" or "vi" to ensure invalid characters are not added to the file when modified with a non-unix text editor.

    Thank you.
     
  20. magicalwonders

    magicalwonders Well-Known Member

    Joined:
    Nov 21, 2012
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Ah, OK. Thanks for the heads up! :)
     
Loading...

Share This Page