suggest how to send mails

Discussion in 'PHP' started by JEET, Sep 14, 2008.

  1. #1
    Hi,
    This is for an article site, where people can submit articles. What I want to do is to send emails to all users when any user submits a new article.
    I can run a loop with a mail function in it, and this is ok with 10-50 users, but what if the site has 1000 users registered?
    How do I send an email to all these 1000 users when any 1 member submits an article?
    Any tips are useful. I'm completely blank here.
    Thanks :)
     
    JEET, Sep 14, 2008 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Do you have rss feeds for ur site.. if so what you could do is register at feedburner and use the email subscribtion option
     
    Bohra, Sep 14, 2008 IP
  3. skimbit

    skimbit Peon

    Messages:
    124
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i suggest you to make a cronjob which runs about every 2-3 minutes and sends out around 50 mails every time. in this case every mail will be sent out without problem
     
    skimbit, Sep 14, 2008 IP
  4. linkexchange1984

    linkexchange1984 Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use effective loop with timer.
    Thank U


    ======================================================
    www.seowebindia.com - Web solutions @ cheap rate.
     
    linkexchange1984, Sep 14, 2008 IP
  5. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #5
    You could use your loop with a sleep() function to send your mail to your 1000 user. You have to use sleep function to pause in a second or two to avoid banned your domain from many email services they will though you are a spammer...lol

    setup a cronjob to execute your loop every 5 minutes.

    cheers
     
    php-lover, Sep 14, 2008 IP
  6. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #6
    Hi,
    Going with a cron job, but here's another problem.
    In the table where I am storing member info, I added a field "lastID" which stores the id of the article which was last emailed to them. Suppose it's 2000
    When a new article was submitted, the new id for article will be 2001 which is different from 2000 in member's lastID. Cron now starts sending email every 5 minutes (sets lastit to 2001). Another article gets submitted in next 3 minutes (2002)
    Now the people who are already sent an email will get another email (different article of course), while people who did not get an email for 2001 will never get it because latest one is 2002.
    What to do here?

    Instead of sending email per article, should I make a list of all articles submitted in 1 day, and set the cron to send this huge list to all members?
    I really wanted to send email per article though...
    Any ideas?
    Thanks :)

    I am thinking of using sleep, but that will make the script slower and slower as new members register.
    Totally confused.
    Thanks :)
     
    JEET, Sep 15, 2008 IP