Welcome Guest, Not a member yet? Register   Sign In
Sending emails out on certain dates
#1

[eluser]Unknown[/eluser]
I've looked through the forums for quite a few pages, and I read the user guide extensively, but I didn't really see the answer to my question.

I'm trying to set up a system to send out emails on certain dates and times. For instance, every Monday at 3am, an email should go out. How would I go about setting that up? I've already got the dates and times stored in my database, I just need to set up something to check the clock and check the database, and if there's a match, send out the emails.

Is that even possible, or do I have to resort to a cron job or something?

Thanks,
Camel
#2

[eluser]Dam1an[/eluser]
I'd say you have 2 options, and if you want the shot version, I'd go with cron jobs

1. Crob job -- Its easy, it works, and there's librraies for CI from crob
2. The endess loop which checks the db every x period of time and does something if necessary, start it off as a background process and leave it -- Feels 'dirty' to me
#3

[eluser]jedd[/eluser]
CI, heck, Apache/http/php/etc - are reactive. So you're a bit limited if you're trying to use them to do something they're not designed to do, such as schedule tasks.

Use cron - it's exactly what it was designed to do well.

If you want to do something slightly ugly, you could use cron to hit (using lynx > //dev/null, say) a web page that generates the emails. A few CMS products use something like this to simplify the bash/binary component of their self-maintenance scripts. It means you can use cron on a remote machine to trigger it, too. That may be useful.

Extrapolating, if you wanted to do something that was truly ugly, and you were confident you were going to get web page hits around the time you wanted, you could have a function (called on every page hit) that first checks if the mail has been sent for that time period, and if not it would a) send it, and b) update the database to indicate the mail was sent.




Theme © iAndrew 2016 - Forum software by © MyBB