I basically have a normal php mail function script that is supposed to run every so often using a cron job, however some emails don't work when they actually work if I run the script manually.
for example in my hoshing cron control panel I enter in domain.ca/pear/Mail/test_mail.php
am I not entering in the url correct? Am I supposed to use some sort of cron job command
require_once('Mail.php');
require_once('../Mail_Mime/mime.php');
$mail = Mail::factory("mail");
$headers = array("From"=>"me@example.com", "Subject"=>"Test Mail");
$body = "This is a test!";
$mail->send("example@gmail.com", $headers, $body);
This is exactly my email script
Also, the cron works with certain email addresses like gmail.
So emails like my schools don't work in cron, but works when executed manually. Also the script updates the database using cron..
I have this in my .sh file :
/usr/local/nf/php5/bin/php -f ./test_mail.php
You can't put the URL alone in a cron rule. Use text-based browser like lynx
or wget
in a cron rule:
* * * * * wget http://mypage.com
You might wish to add some parameters for wget
or lynx
so that it doesn't save outputs on server, instead just simulates the fetch. OR redirect output folder to /tmp
or /dev/null
for it to get wasted. Check man pages of related tool:
man wget
OR wget --help
via Shell.
YOU CAN ALSO do as Artefact2 recommends below: * * * * * php script.php
. You may need to add shebang declaration for PHP at the top of your PHP codes tho:
#!/usr/bin/php
<?php
// your PHP code here
Shebang needs to point to the working PHP executable in your system.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.