PHP Email Response Add Delay

Discussion in 'PHP' started by martin12532, Oct 31, 2013.

  1. #1
    Hi guys,

    I've created a PHP form for my website and have added an email response to it to be sent to the user once they've submitted their details. What I'd like to do is add in a delay of some sort so that the user doesn't immediately receive the email. I'd like to pretend that it's a real person emailing them back instead of them receiving an email 2 seconds after clicking the submit button.

    Any ideas how I'd do that?

    Many thanks
     
    martin12532, Oct 31, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    1) Store the email request on a database or a file based on timestamp.
    2) Create a cronjob/scheduled task to pick up all requests older than X minutes and process/email them.
     
    ThePHPMaster, Nov 1, 2013 IP
  3. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #3
    Only way to do this is to use some kind of scheduled task.
     
    MakZF, Nov 1, 2013 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    But really... why? When I post an email asking for something, it be support, quotes, ordering items etc., I'm happy if I get a reply ASAP. The only things I can understand can be beneficial for something like this, are automated responses to prefilled questionaires etc. or tech support question based on a bunch of select statements in the form. But then, why would they need to be duped by a delayed response.

    I hardly see the benefit, apart from fooling people into believing there's a person answering their emails, which I don't really see the point of doing.
     
    PoPSiCLe, Nov 2, 2013 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    You could use the PHP sleep() function to accomplish this but the page would be sitting there loading before it finally finishes and reaches the end point, assuming your clients have enough patience to wait for this when they check their e-mails and see they received the e-mail right after the page finished loading it kind of kills the effect.

    If you really want to accomplish this useless task I would say either write the information submitted to a file or have it e-mailed to you and then e-mail them yourselves. Even a two minute delay (which I would say is the absolute most a person would wait for a page to finish loading) is going to have them thinking that it was a script that accomplished the sending of the e-mail and not a person.
     
    Pudge1, Nov 5, 2013 IP