SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question newsletter sending / cron / structure

    Right now im planning to create a newsletter sender module. I have all the smtp servers quite running and ready. My lists are ready too. I need now to programa a Cronjob (I know how to do this too) so every 3 minutes some php file is executed and the mails delivered.

    How should my php be?
    Code:
    # get the message to send
    # get the list of non-sent email address
    # send the message to them in a throttling basis ( 20 each 3 minutes, maybe less, maybe more)
    # mark those addresses as "already sent"
    As you can see, Im actually more worried about the logic and structure of the file than the coding. I know how to do this in PHP, but... i have a bad feeling about the logic. I was hoping you to help me find some better way to do this, if there is any.

    Thanks!

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the logic sounds pretty sound...

    store the emails in the database with sent ('0','1')
    SELECT stuff WHERE sent = '0' LIMIT $whatever
    sent
    UPDATE row

    I do the same thing myself in a email marketing application and it works like a charm.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that logic does sounds right. I do just about the same thing in my own newsletter script.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Might want to anticipate the script not finishing on time before the cron job runs again. For example, maybe have 3 states (unsent,sending,sent). You could add a timestamp as well, if you want to be able to handle a script which tried to send, but failed/crashed etc...that way you can detect a "sending" status that is stale.

  5. #5
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great responses! I really thank you weeler, atlantadental and crmalibu! . I was worried about the timing of the script, so the CronJob doesn't have problems oversending the e-mails, an I think that is the same source of problem that a correct throttling has.
    Im currently coding the module. When I finish it i shall test the throttling.. but anyway... have any of you read about the correct mails per minutes in a Gmail SMTP? I tryed "gmal smtp throttling" on google, but got no accurate results.


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
  •