tags:

views:

23

answers:

1

HI. For a client i'm developing 4 different email agents for his web portal. I need to send a lot of emails to clients (couple of thousands in the future) which are stored in a database. Sending is fine, but I would like to work out a PHP script which sends emails, but also stores the previous email domain and if they equal than postpone that email for sending later to prevent spam filters. I'm going to load that script with cron and I already set_time_limit(0); Code sample available at http://mikaelz.host.sk/php/job_robot.txt Big thanks for replies with ideas ;)

A: 

your e-mails are already in a database.

TIMTOWTDI =. there is more than one way to do it.

one possible approach (in pseudo-code):
(a) create a list of objects of PKs (primary keys) with their corresponding e-mail domains;
this could be a list of pairs, of the form:
PK, domain.
(b) create a second, empty list;
(c) order the list from (a) by domain;
(d) send an e-mail the the first item via PK from list (a);
(e) for each subsequent item in list (a), if the domain is the same as
its predecessor, MOVE it from list (a) to list (b),
otherwise send an e-mail via PK from list (a);
(f) continue until list (a) is exhausted;
(g) if there are are items in list (b), MOVE them to list (a)
such that list (b) is empty and list (a) contains the
unsent e-mails.
(h) repeat the above process until list (a) is exhausted
and list (b) simultaneously has zero items.

regards/gerry (lowry)

gerryLowry
Big Thanks. I had a similiar idea, but your summary is simple and understandable ;).The working code sample is @ http://mikaelz.host.sk/php/job_robot.txtPerformance:15:14:31Need to do: 10107Done: 1010715:16:16
michalzuber