Reputation:
I have Linux(Ubuntu) server with MySQL database.
I stored
a. notification date
b. emails
(multiple email accounts)
c. client etc
in a table.
I would like to send an automatic email to each client 30 days before the notification date
. What is the best way to do that?
I have checked several thread over stackoverflow.com and some other tutorials over the internet. I would like to know the steps to achieve this.
Note:
1. Almost same question asked by @Aan in stackoverflow.com, question: [ Sending an automatic email periodically ]. He asked for C#
2. I learned about crontab
yesterday. But, I can't understand the procedure(steps) properly.
3. I don't have any cPanel or webmin to control the cron table. So, I need the shell codes.
Upvotes: 1
Views: 1101
Reputation: 140
The best way is using cron:
First create an script which sends the emails manually. Test it and check that it works.
Now you need to add a cron job for the php script you just created,
if you have cpanel, this is the easiest way to do it. There are
several tutorials around there, for example
http://upstartblogger.com/how-to-create-a-cron-job-in-cpanel/. If
not, you can add it from the console using the instructions here:
http://www.instantphp.com/news/37-tips-and-tricks/138-how-to-add-a-cron-job.html.
Check if it works. Then it's a good idea to use .htaccess to make the file unavailable from the web (so it can't only be run from the cron daemon).
Upvotes: 3