emails with php
OK guys
i have a problem I really can't seem to be able to work out. i have a mailing script that works ok but when the mysql db gets too big it times out so i want to send emails in batches of say 20 at a time
so yoou would click send emails and it would go to a page saying sent 20 of 100 emails, then when they had sent it would refresh and say sent 40 of 100.
nothing i have tried works tho
does any one know how i could do this? just the vague steps not the script
would be really apreciated
J
Greg K posted this at 13:52 — 12th September 2005.
He has: 2,145 posts
Joined: Nov 2003
Is this something you owuld do often? (sending out monthly newsletter)
Or once people in the database get the e-mail, they won't get any in the future?
I have a couple of ideas to do this depending on the answers
-Greg
JP Stones posted this at 17:11 — 12th September 2005.
They have: 2,390 posts
Joined: Nov 1998
hey
an ideas man - thats what i like
this is webbased mailing list manager and i would send out a newsletter at least once a week to this subscriber base.
JP
baldrick posted this at 18:31 — 12th September 2005.
He has: 388 posts
Joined: Apr 2005
You could try using CRON to automate it. here take a look at this http://www.phpfreaks.com/tutorials/28/0.php
JP Stones posted this at 21:49 — 12th September 2005.
They have: 2,390 posts
Joined: Nov 1998
ok thanks vibins. read that and have a few questions
uno: i've never used telnet, is that the only way to run cron? if so my telnet software asked what number to call. i'm running this locally. got confused
duo: can a cron job be started from a script call by a user? the software mentions only time periods.
JP
baldrick posted this at 22:00 — 12th September 2005.
He has: 388 posts
Joined: Apr 2005
You'll need to either have telnet (shell) access to your server, or some other way to interface with it (like 34SP's cron front-end). You'll also have to have a host which allows you to run cron jobs.
As far as i know its only time periods (Stop me if im wrong anyone).
I havent used CRON much but im sure there are people here who are experts at it.
JP Stones posted this at 09:44 — 13th September 2005.
They have: 2,390 posts
Joined: Nov 1998
well if it really can help me in sending 10 emails at a time from a user action then i'm game but i'm not sure it can as it does seem to be purely time based.
can anyone clarify this?
J
Busy posted this at 12:23 — 13th September 2005.
He has: 6,151 posts
Joined: May 2001
A cron is an automated file thingy, you set the time and the file runs, as if someone clicked on that page at that very second.
You can do the same thing with a manual page, what some people do when they run like auction sites they set the cron file (file not job) to the index, so when someone enters the site the index page includes (or requires) the cron file and it does whatever you want it to do.
With the sending of mail you can do a time delayed loop, say send 20 then have the script count to whatever then send another 20 ...
Sending once a week to a very large mailing list would seriously slow down your server, you may want to even send your email a few seconds apart as it will try send 20 per second plus the time to actually go through.
If your server has Cpanel or similar you can set up and run automatd cron jobs from within Cpanel, just set the time, day/s and file to include
JP Stones posted this at 13:35 — 14th September 2005.
They have: 2,390 posts
Joined: Nov 1998
ok that is promissing. ill start reading up on that busy.
do you think it would be possible to to the same thing with nested loops?
loop thats pulls out all emails from database
loop that sends 10 emails at a time
goes back to top loop, ads 10 to the total and then sends another 10 emails
something like that?
JP
Busy posted this at 21:39 — 14th September 2005.
He has: 6,151 posts
Joined: May 2001
Sounds like the best way to do it, otherwise if you just pulled all the info out and waited it would time out.
first loop should only be 10 or limited to what you send at once (go up to 100 if you have thousands, remember this will try send this amount a second).
You could even have a short pause between loops, even a second or two would be noticable on the server, and your host might like you more lol
The down side to this is resources, if you have thousand or so emails to send it will take a while, so best time would be to do it in your quite time if you can work it out from your logs
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.