send email from a mysql database

Discussion in 'PHP' started by beermaker74, Feb 22, 2007.

  1. #1
    ok here it goes. I have a page where the user can enter a search term for them to be emailed at a frequency they desire. The search page has a bunch of terms lists etc and a place for their name email and the frequency they want to be emailed. ie once a day, week , or month. This page goes to another page where all this info is entered into a mysql database. name email frequency and search query. So I want to set up a cron that sends the emails out. This is where I am a bit curious at what you experienced programmers would do. Should I have 3 pages. ie one script for day emails,one for week and one for month emails? Then set up a cron for each one. As well what would be the best way to go thru the database and email each query. I was thinking of some for loop. that pulls the data where frequency = days then loop thru each row and perform a query then email that result. Does this sound like the right course of action? Well i appreciate any advice you can offer
    thanks
     
    beermaker74, Feb 22, 2007 IP
  2. SilkySmooth

    SilkySmooth Well-Known Member

    Messages:
    1,583
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    180
    #2
    Personally I would just develop this in one PHP script that is run on the cron daemon rather than 3.

    Select the users that are to be contacted and loop through them, then select the data that is to be delivered to them, send the email and voila, job done.
     
    SilkySmooth, Feb 22, 2007 IP
  3. rays

    rays Active Member

    Messages:
    563
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    you have one more option ... try searching about the triggers in MySQL .. so that for each insert operation on database you can check for the new entries and will be able to send emails to users using some other method in phjp
     
    rays, Feb 26, 2007 IP