views:

622

answers:

3

Hi all,

I'm new to codeigniter, and I'm trying to figure out how to implement a weekly digest, sent to members.

I currently have the email set up correctly, and now am trying to get the 'weekly' part down. I know how to use date / time functions to check if one week has elapsed, but how do I run something, say, 'every monday at 8pm' without having to click on my site. Can I do this in CodeIgniter ?

Thanks,
Michael

+4  A: 

You don't want the email helper but rather the email class. Check out the documentation. The instructions explain themselves. The only advice I can give you from experience is:

  • Use SMTP. It has performed better, is less susceptible to spam filters, and much more smoothly works across different servers in my experience. You need to pass five configuration arguments, protocol and the four smtp_ arguments.
  • Save your settings as a config file (check the docs). It will save you some headaches.

In terms of creating it, you can either do it manually or create it automatically from a database. If you do it manually, just set the emailing script as the output script, and you're done.

If the newsletter is made automatically, and if you don't have that many users, setting a cron job that runs the emailing script will do just fine. If you have a lot of users, send it out in batches.

Other things to think about:

  • Don't send out a single email with multiple addresses in the To or BCC fields. Just loop through the emails one at a time and send them. It'll be better for spam protection and it makes more sense. People don't like receiving emails that aren't addressed to them or are addressed to hundreds of others.
  • Put up some universal failsafe script that prevents emails from being sent too often. A simple fwrite to a log file with the most recent mailing date would do the trick. Alternately, you could keep a DB of all sent emails and the time they were sent.
Steven Xu
And if anyone else is interested -- cron can call a php file through the use of 'wget' :)
Michael
A: 

Here you can watch a screen cast. How to send email using codeigniter.

And here you can watch a screen cast How to make a Newsletter signup page using codeigniter.

shin
A: 

i don't know.............

sharmi
Thanks for sharing.
Greg