Results 1 to 7 of 7
  1. #1

    How to send thosands of mails efficiently

    Hi,
    i hav to send some promotional mails to thousands of users after every 15 days, there are 7 to 8 different types of mail which goes to every customer in a particular order....can u tell me how can i optimize this process coz there are arroned 2 to 3 lacks users and i dont want to send all of them at once, i m trying to make a webservice which execute after every 1 hour, but facing one one problem how to break the number of records, dont want to make a temporary table..
    thx

  2. #2
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    If it's legitimate marketing (opt-in) email your best bet is a decent list server, although they aren't cheap, but they do at least have their own SMTP servers to balance the load and handle unsubscribe requests and bounces automatically for you.

  3. #3
    hello!
    If you have unique id assigned to each of your addresses you might consider creating doing the following:
    1. script send messages to 300 users (just an example number) starting from the very first from your base
    2. script outputs the id of last user to a file (e.g. lastuser.php)
    3. after 1 hr go to step 1 and repeat starting from the id read from lastuser.php

    The solution might increase your server load a bit but that's not an issue since the database is relatively not big and requests are made only once an hour.

    P.S. PHP gurus, please, don't kick me It's just a try

  4. #4
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    Originally posted by Quickcess
    hello!
    If you have unique id assigned to each of your addresses you might consider creating doing the following:
    1. script send messages to 300 users (just an example number) starting from the very first from your base
    2. script outputs the id of last user to a file (e.g. lastuser.php)
    3. after 1 hr go to step 1 and repeat starting from the id read from lastuser.php

    The solution might increase your server load a bit but that's not an issue since the database is relatively not big and requests are made only once an hour.

    P.S. PHP gurus, please, don't kick me It's just a try
    It really depends on how many addresses there are, whilst it might not put a load on your PHP script it has got a good chance of loading your SMTP or mail program.

    If it's only 300 an hour then it would probalby be fine, so long as you don't have a PHP exeuction timeout that you reach!

  5. #5
    Join Date
    Jun 2002
    Location
    Sherbrooke, Québec
    Posts
    182
    What about loading the list into a SQL database? You could then use a column which acts as a flag to tell wether or not the mail was sent out. Send one bunch of mails with (example):

    SELECT * from SOMEDB WHERE sent='no' LIMIT=300

    Just an idea, never tried myself.

    Also you should give a short dalay between each e-mail sent (200 ms is enough) to let the SMTP server relax a bit and not monopolize it. You should also make sure that you're script won't expire (by default a script is stopped after 30 secs).

  6. #6
    Join Date
    Apr 2004
    Location
    Israel
    Posts
    17
    Yeah, we do that. The actual system is way more complicated though; there are normalized tables for types of emails to send, a scheduler and, a bot that oversees load, bounce messages, scheduling, and the cron job that performs the scheduled tasks..

  7. #7
    Join Date
    Nov 2002
    Posts
    202
    what you need is pear's mail_queue. the forum gay'ed me saying i cant post url's until i post 5 messages O_o.. so just google this "pear mail_queue", you'll get it

    enough said

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •