Advanced email script to send at a specified time?

Discussion in 'PHP' started by Sapphiro, May 4, 2009.

  1. #1
    Hi there people, I'm just curious cause I had an idea for a new site.

    Does anyone here know how I can create a php email form that will send emails only at the user-specified time? :D I've done some research but to no avail, I only read about something called chron but I'd prefer to just use plain php if it's doable. Any php syntax for that? For the mail(); method. :D



    With Regards,
    Felix
     
    Sapphiro, May 4, 2009 IP
  2. tradeout

    tradeout Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Cron would be the method to use. There is no PHP method to delay submission for a specific time.

    I would suggest you store the form submission in a database, then have a cron run every minute to check what emails need sending and process them accordingly.

    All very simple- if you need some help let me know.
     
    tradeout, May 4, 2009 IP
  3. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #3
    hmmm then may I know how to use cron? Do I have to install anything or stuff like that? :) Thanks for your eagerness in helping out! :D
     
    Sapphiro, May 4, 2009 IP
  4. tradeout

    tradeout Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Dependant on where your site is hosted, there should be options for cron jobs in the admin panel.

    You would the set the cron job to call your PHP file, which would do the required business checking and sending the emails.
     
    tradeout, May 4, 2009 IP
  5. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #5
    yeh, my host has it. Do I have to type out some linux commands to relate to my php mail function or something like that? :)
     
    Sapphiro, May 4, 2009 IP
  6. tradeout

    tradeout Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Not usually, when setting it from within a control panel. Just select when you want the cron to run and enter the PHP file name that needs to be executed.
    Then you need to have all the script that checks/ sends the emails etc in that PHP file.
     
    tradeout, May 4, 2009 IP
  7. bluebenz

    bluebenz Well-Known Member

    Messages:
    876
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    138
    #7
    I think cron is the only one possible solution for this (although there is a cron service by 3rd party website, it's still a cron).

    Let see:
    1. save the email content on database with the time you want that email is delivered.
    2. create a php file (example: send_email.php) that always check the time, and if there are email need to be sent at that time, sent them
    3. create a cron, run send_email.php each 1 hour

    what do you think?
    this is a dummy solution..
    :)
     
    bluebenz, May 4, 2009 IP