It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

mailing list and cron

Moderator: Malcolm

mailing list and cron

Postby john_zakaria on Wed Aug 26, 2009 7:43 am

now i want to make a mailing list .. i want to send a mail up to 2000 user. but the server only allow sending 200 mail at once so i want to make a cron job that make the following task.
1- send mail to 200 user
2- i have a database that have a filed name e-mail that contains mail address and
flags field that contains zero or one
zero -> not sent yet
one -> e-mail sent

3- change the flag in the database from zero to one

4- after an hour the cron will run again and send the mail to the fields of database that have the flag zero.. and i will make the cron run until there is no flags zero so that all mails are sent..

my problem is that i dont know how to work with cron job from PHP i want to know how to run cron Job from php??

NOTE THAT: when the user press send button it will create the cron job for sending the 2000 mail and run every hour to send 200 mail per time ..

can any one help me plz
john_zakaria
50+ Club
 
Posts: 59
Joined: Sun Feb 08, 2009 7:29 am

Re: mailing list and cron

Postby dflynn on Tue Dec 29, 2009 5:40 am

Hi John,
Running a cron job is done in UNIX. If you don't have direct control over your server, (you're not self hosting) then you will likely have an option in your control panel with your host to set up a cron job. All you'd have to do is point to the right file and click a few links.

As long as your PHP is good, it should all work.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: mailing list and cron

Postby flabbyrabbit on Tue Dec 29, 2009 12:30 pm

As dflynn said, I don't believe you can create cron jobs from php. But using abit of imagination im sure you can find a way to do. For example you could have a cron job running every hour that checks a value somewhere that would have been set in when the user presses send. So if the variable has been set then send messages else do nothing.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Re: mailing list and cron

Postby dflynn on Tue Dec 29, 2009 1:45 pm

For something as simple as mass-email you probably don't even need a cron job. Because you need to have the email created (unless you're essentially emailing out an RSS style feed) you'd need to take the time to prepare it before you send it. Adding a cron job would just add to the stress of having to have that email ready on time.

What you might want to do is just add a page to your administrator section of your site, or any password protected directory, and have the php cycle through on the click of a button, 200 at a time.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: mailing list and cron

Postby flabbyrabbit on Tue Dec 29, 2009 2:41 pm

Form what I gathered he has a similer problem to me. With my host I am only allowed to send a certain amount of emails an hour.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England


Who is online

Users browsing this forum: No registered users and 2 guests