CodeIgniter Forums
Problem with timing to send mails, sleep of 15 minutes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Problem with timing to send mails, sleep of 15 minutes (/thread-9584.html)



Problem with timing to send mails, sleep of 15 minutes - El Forum - 06-30-2008

[eluser]Rubiz'[/eluser]
Hello!!

Well, I'm with a problem, more logical than freak...

I built a logic script for sending mail marketings, but my host cant send more than 50 once, it must be:

- send 50...
- wait 15 minutes
- send more 50...
- wait more 15 minutes..

This is relatively ease to do, I made it with the sleep() PHP function, to make the waiting 15 min. but I'm getting this error: MySQL server has gone away.

I would like to know what s#$%t is that, and how I could solv this problem... anyone has any idea?

Thanx...


Problem with timing to send mails, sleep of 15 minutes - El Forum - 07-01-2008

[eluser]gon[/eluser]
Keeping a PHP script running for hours is not a good idea, from my experience.
I would insert email recipients in a DB table,
then would call a PHP script every 15 minutes using CRON. The script would send 50 emails from the DB, erasing them, and exit.
If there is nothing to send just exit and you're done.


Problem with timing to send mails, sleep of 15 minutes - El Forum - 07-01-2008

[eluser]Rubiz'[/eluser]
I have made this question already and people told me about that, acttualy I really don't know what is "CRON"... what is it?


Problem with timing to send mails, sleep of 15 minutes - El Forum - 07-01-2008

[eluser]gon[/eluser]
Cron is a program that executes periodic tasks on UNIX-like systems, Linux, BSD etc.
If you use Windows, there is also a system for this, although I found it to be quite buggy under Windows Server 2003 some time ago. Google for that.

Anyway, the procedure is going to be the same. Learn how to use the method available in your system, and prepare a codeigniter script that will be executed as a cron task, as described here.


Problem with timing to send mails, sleep of 15 minutes - El Forum - 07-01-2008

[eluser]Rubiz'[/eluser]
This looks very advanced to me Gon, I'll try make something with refresh or prototype, thanx for your help! Smile