Email not working through CRON

Asked by:
HubFans / n/a Points
Time:
2015-01-28 5:49 pm EST
Category:
Email Troubleshooting
Hits:
1,265
I have written a code to send me the email when a cron runs but the email is not coming to me but when I run the same script through browser then I can get the emails. Please get my problem resolved ASAP.

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

arnelc
Staff
17,314 Points
2015-01-28 6:10 pm EST
Hello,

Apologies for the problem with sending email through PHP in using a CRON job. The problem you're facing is a result of the web environment having a different environment (set by a PHP.INI) versus the command line. When you're running the CRON job it's running in a different environment with a different set of PHP variables. If you're not setting them correctly in your code, then your cron job that set to send mail in PHP will NOT work. Here's the email log error that we're seeing:

SMTP error from remote mail server after MAIL FROM:<> SIZE=2836: host 127.0.0.1 [127.0.0.1]: 550 "REJECTED - Bad HELO - Host impersonating [ehub22.webhostinghub.com]

I spoke to a senior tech about it after looking at your cron job and making sure that it was running. I also compared running the cron job with the running it in a browser. The senior tech confirmed that the issue is within your code. You will need to provide further variables within the code in order to get the mail to send properly. Our apologies as we cannot edit your code for you. You may find some information here in regards to the issue.

(I also removed your question from InMotion support center as it was a duplicate of this one)

Kindest regards,
Arnel C.

To submit a comment on this answer, please first login.

I have checked and made the changes as per your suggestion but there are still problems and I am not able to get this resolved. Could you please suggest me where should I make what changes to get this corrected? Also let me confirm you that if I put "echo 'Hello'"; inside the cron script then I get a mail from cron and that mail has the content as "Hello". So there must be something wrong on the server setting.
karnsingh
22 Points

2015-01-29 1:45 pm EST
Hello karnsingh,

Thank you for getting back to us. When I navigate to the script in a browser (http://karnsingh.com/reminder/cron.php), I see the following message:
Mail sentMail sent

This indicates that the script is working, and there is not a problem with the PHP environment, but with the coding of the PHP script instead.

When you are sending mail, you must authenticate with the server using a username and password. Typically, you would accomplish this by using your specific email settings.

Since this file is located in a public folder (public_html), ensure the cron.php file cannot be read publicly. You can do this by setting the permission levels accordingly.

Thank you,
John-Paul
johnpaulb-whh2
12,339 Points
Staff
2015-01-30 2:13 am EST
0

karnsingh
2015-02-03 5:44 pm EST
I got some more changes done as you suggested but still no luck. Could you please have a look on this again?

To submit a comment on this answer, please first login.

When accessing the file directly, do you get any errors? Is the email sent?
JeffMa
2,342 Points
Staff
2015-02-03 6:10 pm EST
When accessing the file directly then I get no error and I get the email normally.
karnsingh
22 Points

2015-02-03 6:58 pm EST
When sending from the command line such as how a cron job works, you may need to fully authenticate with the server as the user that is sending the mail. To do so, you may use a script such as PHPMailer to authenticate and send the message.
JeffMa
2,342 Points
Staff
2015-02-03 7:46 pm EST
I am already using the PHPMailer to send the email. If you check my script then you will see the same.
karnsingh
22 Points

2015-02-04 6:06 pm EST
Hello Karnsingh,

Apologies, but the main issue here is that your script is missing some settings (not necessarily the credentials), that are required when running through SSH versus running in an internet browser. This easily seen when looking at errors in the Apache error log. Here are the errors I'm seeing for you:

[Tue Feb 03 08:03:57 2015] [error] [client 203.122.17.90] Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so: /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so: undefined symbol: zend_new_interned_string, referer: http://www.karnsingh.com/reminder/create_reminder.php


Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so: /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so: undefined symbol: zend_new_interned_string, referer: http://semalt.semalt.com/crawler.php?u=http://karnsingh.com


These look to be related to the same issue. We unfortunately cannot correct your script for you. We can try to point you in the right direction though. You may otherwise want to consult with a programmer/developer who can help you with this issue. If you need more information about the PHP.ini that you're working with in SSH, please run PHP -i at the command line.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.


arnelc
17,314 Points
Staff
2015-02-04 6:36 pm EST
I don't have anything related to Zend or ION Cube loader in my code then why would this error be related to my code?
karnsingh
22 Points

2015-02-05 4:14 pm EST
This is due to your php.ini file. Simply adjust your php.ini file to remove the lines referencing IonCube and ZendGuardLoader.
JeffMa
2,342 Points
Staff
2015-02-06 10:48 pm EST
Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}