开发者

Postpone email when domains equal

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 开发者_StackOverflow社区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


Your e-mails are already in a database.

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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜