php mass email and reminders
I am working on a site where I have the admin manager and i am trying to see how can I allow the admin to send mass emails to notify the event he is organizing, once he invites for the first time then towards during the event date, cron job should automatically send reminder to the author the email id's he used first time. something like how evite does. would like to learn these functionalities and also if poss开发者_Go百科ible how to send email if the event is canceled or postponed.
regards
One way to do this would be to have an OutgoingEmail table, and in that table store the date/time that the email should go out, the email address, subject, and body.
When the event is organized, generate the contents of the email and insert a record for each attendee with the current date/time. If the admin selects for a reminder to go out, also insert those emails with that future date/time. When the event changes, clear out any pending outgoing email records for that event, and insert records for an 'event changed' email (and if necessary, add new reminder emails with the updated details.)
Create your PHP script that will run from the crontab, and have it query any records in the OutgoingEmail table with date/times in the past. Loop through them using the PHP mail() function and delete them as you send them successfully.
Schedule it to run every 10 minutes or so, and you should code a routine to ensure that only one instance is running at a time. In the past I have created a 'lock' file, and the start of the script would check for the lock file. If the lock file exists, quit. If it does not exist, create it, process emails, and then remove the lock file.
Do you have more questions?
I would look into the PHP Mail functions. They also have solid examples and more can be found online as well. Use something server side to keep track of dates for when to run the scripts
I would use this class for sending emails, i have used for years and is very tidy.
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/
then run a query on the table say where the date is in 14 days time and send an email with that class. Make sure you highlight the table rows with a reminder sent just in case that file gets run again before the next day, people will get really annoyed if they get more than one reminder.
精彩评论