Jump to content


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

  • Please log in to reply
3 replies to this topic

#1 betoranaldi

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 June 2006 - 11:24 PM

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"

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?

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,

#2 nogray

  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 24 June 2006 - 12:31 AM

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.


#3 betoranaldi

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 June 2006 - 01:13 AM

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.

#4 Allen4172

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 24 June 2006 - 12:19 PM

[!--quoteo(post=387337:date=Jun 23 2006, 09:13 PM:name=betoranaldi)--][div class=\'quotetop\']QUOTE(betoranaldi @ Jun 23 2006, 09:13 PM) View Post[/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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users