Sending An Email

Can i send an email using the mail command, so that the email will
be sent in X time.

i.e user signs up and they pick send my activation email in
X minutes.

I dont want a complicated script or run a cronjob, so if its not possible
i'll take the feature out.

Thanks In Advance...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

no, unless you find in the RFC some obscure header for this purpose :D

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

how about using the 'at' command?  or is this too close as to be called a cron job?

1)  create a two line script named '' which looks something like this.  (note, the tmpfile.txt is created in step 2:

/usr/sbin/sendmail -t tmpfile.txt

2)  when user submits form, create the email as a temporary text file tmpfile.txt that looks something like this (obviously replacing recipient with the user's email address):

Subject: Here's your email

Blah blah blah blah blah blah blah
more blahs
even more blahs

(take note of the last period on the line, this will give a clue to sendmail that this is the end of the file (even though it probably doesn't need that clue. ;) )  Also the blank line between subject and Blah is important.)

3)  after creating the temporary file, now do something like this in your script:

  exec("/usr/bin/at -f + $minutes minutes");

where $minutes is how many minutes they want to have the email sent.  This could also be + x hours, days, weeks, months, years, etc.  Or even 'at 10am Jul 31'.  Lots of options.  Check out the man page for 'at'.

That wasn't too bad, right?  =)

If you get mass amounts of use, you'll probably need to perform some sort of file locking on file.txt so that multiple scripts don't overwrite it.  Something stupid might be:

  while (file_exists("tmpfile.txt")) {

  // create tmpfile.txt

  // run exec() function


there's much better file locking than this in PHP using flock():

lots of typing for 20 pts. ;)
yes, definitely too close to a cronjob ;-)
tsPHPAuthor Commented:
Sorry for the delay in the reply i was off work..

I am going to award the points to VGR as he did point out
in the first place that i couldn't do it.

Thanks alot for both your answers.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.