SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2008
    Location
    Gloucestershire, UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending Multiple Emails With PHP

    Hello,

    I'm working on an online shop, and they're keen on email marketing but concerned about putting too much strain on the dedicated server when sending what could be a couple of hundred emails.

    I don't know very much about it myself, so would a dedicated server have any problems performing this kind of task?

    Also, is it best to loop through a database of email addresses and send an email to each address, or would it be better to send a single email to multiple addresses (if there is any difference)?

    Cheers,

    Jon

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A couple hundred mails is not a problem, it won't put any strain on your server. You can send them one at a time, I don't think a huge BCC list would be better. Just take care that your mail services are well configured or the mail will end up in spam bins instead of inboxes.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    PHP only sends the email to the email server, so it mostly depends on what that can handle and if the host has imposed limits. IMHO a couple of hundred shouldn't be a problem, but it could grow into one as the list grows.

    Do you need to send all the emails within a set time frame? Maybe you can break the task into smaller chunks and spread the load out?

    If your database server is prone to errors, then BCC:ing list members would be better than looping 1 at a time, otherwise I don't think it will make much difference for you at this point.

  4. #4
    SitePoint Addict joaquin_win's Avatar
    Join Date
    Jul 2005
    Location
    Venezuela
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BCC'ing too much (and to many) can be considered spam

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Yes, DreamHost has a limit of 50

  6. #6
    SitePoint Zealot
    Join Date
    Jun 2008
    Location
    Gloucestershire, UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would it help if I put the script to sleep() for a couple of seconds between each email, and if I did, would the script stop executing if the browser window was closed?

    Cheers,

    Jon

  7. #7
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You don't have a problem, so what are you trying to fix?

    You should run your script from the command line, not a browser.

  8. #8
    SitePoint Addict joaquin_win's Avatar
    Join Date
    Jul 2005
    Location
    Venezuela
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I made the mistake of sending emails newsletter triggered by a browser based user interaction. But if the user closes the window you are done.

    Best way is to do a command line utility like Dan Grossman says, or go with cron jobs.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    If you're careful to use a set_time_limit() so you don't overtax the server you could risk ignore_user_abort(true)


Bookmarks

Posting Permissions

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