Jump to content

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


betoranaldi

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
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.