Problem testing cron for email output

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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('[email protected]','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
 

Attachments

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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 ?

[Tue Sep 02 15:32:24 2014] [notice] Status engine is currently disabled, enable it by set SecStatusEngine to On.
[Wed Sep 10 07:06:27 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)

[Wed Sep 10 07:06:27 2014] [warn] RSA server certificate CommonName (CN) `webhost1.domain.com' does NOT match server name!?

[Wed Sep 10 07:06:27 2014] [emerg] mod_qos(007): could not determine MaxClients/MaxRequestWorkers! You MUST set this directive within the Apache configuration file.
[Wed Sep 10 16:51:33 2014] [error] [client 91.125.145.246] suexec failure: could not open log file
[Wed Sep 10 16:51:33 2014] [error] [client 91.125.145.246] fopen: Permission denied
[Wed Sep 10 16:51:33 2014] [error] [client 91.125.145.246] Premature end of script headers: arp3-install.pl
Extract from suexec log
[2014-09-10 19:26:58]: file has no execute permission: (/home/internet/public_html/cgi-bin/arp3/arp3-install.pl)
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!
 
Last edited:

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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? -

First check if PHP-scripts can send emails

php -a
mail ('[email protected]', "Test Postfix", "Test mail from postfix");
exit ();

Note: if after running php -a, you get "Interactive mode enabled" message but no php> prompt, then your PHP is not compiled with readline support. If its working nice, you will get only "Interactive mode" message with php> prompt.

You can still run test though. Just create a testmail.php with following lines of codes:

<?php
mail ('[email protected]', "Test Postfix", "Test mail from postfix");
?>

and run it on your server with php -f testmail.php command. If you can’t see any email form PHP, then that means its PHP’s fault.
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!
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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.
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 -

Upon checking we could see that reference /etc/mailips for SMTP outgoing connection is disabled in the server and we have enabled it.
That seemed to fix the SPF and DKIM, but I'm wondering if it could have messed up the Mail at the same time?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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

Default PHP Version (.php files) 5
PHP 5 Handler suphp

Apache suEXEC on
Apache Ruid2 off
And the new one as follows -

Default PHP Version (.php files) 5
PHP 5 Handler suphp

Apache suEXEC off
Apache Ruid2 off
I'm not sure what the consequences of this difference is.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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 <[email protected]>: "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=<[email protected]> temporarily rejected RCPT <[email protected]>: lowest numbered MX record points to local host
2014-09-14 09:02:44 H=avasout02.otherdomain.net [212.159.xx.xx]:50969 F=<[email protected]> temporarily rejected RCPT <[email protected]>: 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! :)
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
You should configure "Apache suEXEC" to "ON" to match your source server if you prefer the same setup.

2014-09-14 09:02:43 H=avasout02.otherdomain.net [212.159.xx.xx]:50969 F=<[email protected]> temporarily rejected RCPT <[email protected]>: lowest numbered MX record points to local host
Make sure the domain name is in your /etc/localdomains file if it's email is handled locally.

Thank you.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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.
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 -

Could you please update us the PTR record needed for the IP address which is mentioned below, so that we can set the rDNS for you.
I'm not sure where to find this information?

Hope you can advise.

Many thanks,

Myles
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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
 

Attachments

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

magicalwonders

Well-Known Member
Nov 21, 2012
112
2
18
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
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?
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.