Timed emails

Discussion in 'PHP' started by jamessy, Nov 2, 2009.

  1. #1
    Hi I am trying to get my head round this. When a user fills in a form it will send them an email straight away but I then need to send a different email to the user 2 days later and then another 2 emails at other 2 day intervals. What would be the best way of doing this in php?

    Any help would be grateful.
     
    jamessy, Nov 2, 2009 IP
  2. jgalvez

    jgalvez Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Keep a record of the email addresses and when they signed up, as well as the last time you sent an email, in the database. Then you can create a cron job that grabs a list of people who need to be emailed again, (check the time in the database and see if 2 days had passed) then send out those emails and update the timestamp of when you last sent an email.
     
    jgalvez, Nov 2, 2009 IP
  3. jamessy

    jamessy Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry I have no experience of a cron job is the script easy enough to write? could I learn this over the next few days?
     
    jamessy, Nov 2, 2009 IP
  4. organicCyborg

    organicCyborg Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    A cron job can be tied to a normal PHP script (or whatever you've written your email program with).

    So, you'd write a script that searched the database for all the users who need to be emailed and then link the script to a cron job that was executed every day.
     
    organicCyborg, Nov 3, 2009 IP
  5. jamessy

    jamessy Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the advice
     
    jamessy, Nov 3, 2009 IP
  6. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    mate firstly, you need to save email address inside a database..
    then you need to create a script that appends these emails from the database and has your newsletter.
    the script will be ran by you every 1 or 2 days..
    similarly, you can create cronjob or scheduled job will run your script automatically each 1 or 2 days.
     
    xenon2010, Nov 4, 2009 IP