Email Script - Execute once a day?

Discussion in 'PHP' started by adamjblakey, Nov 14, 2007.

  1. #1
    Hi,

    I have a page that sends an email to anyone that has chosen to receive emails alerts. The way the page is set-up at the moment is every time someone posts a new item a email is sent to the users who want to receive emails.

    The way i want it to work is for the email to be sent once a day at a certain time with all the items that have been posted that day. So that the user does not receive e.g. 10 emails the same day and just receives one with all that days information.

    Cheers,
    Adam
     
    adamjblakey, Nov 14, 2007 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think that you are asking how to set up timed events. This probably depends on how you are hosting your site. If this is being hosted by a unix/linux server you can set up a cron job to execute a script at a given time. To do that you'll need either shell (via ssh or telnet or something) or an administrative gui that lets you edit cron entries. If you are doing this from a shell you can run "crontab -e" to edit your cron jobs. An example cron entry might be executed everyday at 2:30am:

    30 2 * * * /home/myusername/www/sendEmailsNow.php

    And then put your email code into /home/myusername/www/sendEmailsNow.php

    If this isn't unix/linux though, well then cron isn't going to help you :)
     
    drunnells, Nov 14, 2007 IP
  3. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #3
    hi, you can probably do this through cron, just create a script and schedule it to run once a day.

    If you need this done for you, i can probably help :)
     
    serialCoder, Nov 14, 2007 IP
  4. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #4
    this is a very good point to take note of :cool:

     
    serialCoder, Nov 14, 2007 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Hmmm...

    I have never done cron jobs before.. I am using a linux server though so should be able to pick it up.

    Can anyone point me in the right direction on where to learn how to do this?
     
    adamjblakey, Nov 14, 2007 IP
  6. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #6
    hmm, i'm not sure if i'm allowed to post links here so i suggest you use google and search for cron job :)
     
    serialCoder, Nov 14, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    Have a look at your cPanel. Usually there's an option to set cron jobs. And it's easier this way too. (In most cases)
     
    nico_swd, Nov 14, 2007 IP