Jump to content

Archived

This topic is now archived and is closed to further replies.

betoranaldi

Building an email Application w/ cron jobs and have a few question

Recommended Posts

Well first I want to say is that PHP is a hobby of mine and I am still learning. I figured what better way to learn then create an application not just a script here or there. I have already learned quite a bit but have some questions and need some clarification.

The application I decided to creating is a newsletter/email campaign mailing system. I have it set up so that the person will upload the mailing list(s) then upload the selected email(s) and then there is another table (campaign) that tracks which email will be mailed out to what list.

My thought is to have a cron job script run every 15 minutes and check if there are any "pending" campaigns to send out. If there is a pending campaign the campaign's status will be set to "in progress" and the script will start to send out the emails. I plan on using the sleep() function in order to send out 6 emails a minute. When the script is done it will set the campaign status to "sent" and send a notification email stating the the email has been sent.

1) Do I need to use the set_time_limit(0); function on this cron script?

1a) Will it timeout without it even though the script is not running through apache?

2) Will I notice any drain on the server with this type of setup?

3) If the server was to reboot in the middle of the script being executed will the process stop and not send anymore emails?

3a) If this is the case what would be the best way to "resume" where the script left off? I would rather not add anymore columns to the tables.

4) Does anyone see any problems with my "process"

::edit::
5) if the cron script is in the proccess of running and 15 minutes pass and it comes time to run the script again, will it stop the current process and start over? or does it start a new process in tandem with the frist?
::edit::

Currently there is 327 recipients in the database for the first newsletter that I plan to send out.
Each email is going to be customized with the recipients name and will have an opt-out link at the bottom.

Thanks in advance,
Brian

Share this post


Link to post
Share on other sites
327 emails can be sent in a few seconds if you setup your script correctly. If you plan is sending mass email, don't use php native mail() function because it's very slow.

You can use the PEAR Mail package at http://pear.php.net/package/Mail

or PHPMailer at http://phpmailer.sourceforge.net/

if you are on a shared hosting plan, check with your hosting company on mailing limitation.

Share this post


Link to post
Share on other sites
Well its a VPS that I own so I am not too worried about limitations. Although the list is small now, I can see it growing.

I will look into PEAR and I have some PHPMailer experiance, can these be used with a cron job? I believe my question are still valid with these.

Share this post


Link to post
Share on other sites
[!--quoteo(post=387337:date=Jun 23 2006, 09:13 PM:name=betoranaldi)--][div class=\'quotetop\']QUOTE(betoranaldi @ Jun 23 2006, 09:13 PM) [snapback]387337[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I will look into PEAR and I have some PHPMailer experiance, can these be used with a cron job? [/quote]

Not sure how familar you are with running CronJobs but they they basically just execute a page ever XX minutes you set. Cronjobs run whatever you tell it to run, so you can execute any links/scripts with it.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.