Reputation: 953
I have the following PHP file which is used to send a simple email, I have tried to open this php file by a browser, so to execute it, I can successfully receive the email. However, when I try to send it buy a window scheduler, I am not able to do so. The way I open the file in scheduler is C:/xampp/htdocs/mail.php, I have tried to check the log of Mercury, but no mail is received by Mercury, so probably mail.php is not being executed. May I ask why it cannot be scheduled to run?
Here is my mail.php:
<?php
mail('[email protected]', 'Mercury test mail', 'If you can read this, everything was fine!');
?>
Taking the advice I have made changes, but still the email cannot be sent
Upvotes: 0
Views: 1270
Reputation: 39
Run a PHP file from Command Prompt.Try this Command
"C:\xampp\php\php.exe" "C:\xampp\htdocs\test\Yourmailscript.php"
Upvotes: 0
Reputation: 33542
It looks like you are scheduling it incorrectly.
To use Windows Scheduler or to run a PHP file from a command line, you need to use the following format:
C:\path\to\your\php.exe -f 'C:\path\to\your\actual.php'
That should then run your script.
Additionally, you often configure the php.ini
that the CLI uses to be different, so make sure that your settings for SMTP and the like are consistent between them.
Lastly, if you want to know what happens during your script, you can have them echo out text (so use things like \n
for new lines etc, and output to a text file like this:
C:\path\to\your\php.exe -f 'C:\path\to\your\actual.php' > 'C:\path\to\where\you\want\logfile.txt'
Upvotes: 2