943,929 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1981
  • PHP RSS
Jan 7th, 2009
0

help sending email at a future date using php

Expand Post »
hi, i'm a newbie to php and i'm building a website right now. i giving the users the option to create and send
news letters. i also want to give them the option of sending the newsletters at a later date i.e they can create the newsletters, choose a date and time they would like to have it sent, and then save it, so that at the said time, the mail would be automatically sent.
can anyone help me out with this?
i heard about cron, but it seems its just for unix users and it seems kind of complicated. does anyone have a simpler/better alternative?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cali_dotcom is offline Offline
51 posts
since Apr 2008
Jan 8th, 2009
0

Re: help sending email at a future date using php

Hi,
I have one simple idea. Store your prescribed date and time in a php variable. Then get system data and time in another variable.
Now, check the condition if system date and time is equal to prescribed date and time, if it is ok then send email else dont send your email. Am i right?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ashafaaiz is offline Offline
20 posts
since Dec 2008
Jan 8th, 2009
0

Re: help sending email at a future date using php

unless your site has a constant consistent flow of traffic, cron (nix) / Task Scheduler (windows) would be the only way to accurately do this.

On windows you would need to use the task scheduler. http://www.sugarcrm.com/wiki/index.p...ux_or_Mac_OS_X
This is specific to SugarCRM's setup, but the concept is really easy and you should be able to figure it out.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Jan 9th, 2009
0

Re: help sending email at a future date using php

php Syntax (Toggle Plain Text)
  1. <?php
  2. if (date('j, n, Y') == '10, 3, 2009') {
  3. mail('mail@example.com', 'Subject', 'Message');
  4. }
  5. ?>

Ive not tested it but it should work
Last edited by !Unreal; Jan 9th, 2009 at 7:49 am.
Reputation Points: 11
Solved Threads: 2
Junior Poster
!Unreal is offline Offline
112 posts
since Dec 2007
Jan 9th, 2009
0

Re: help sending email at a future date using php

That is a perfectly fine solution, but unless there is someone visiting that page on that date at a certain time, there is no way to force it to be sent:
  1. user creates the email
  2. user schedules it for 01/10/2009 @ 15:00:00
  3. user exits
  4. no new visitors till 01/13/2009
  5. email doesnt send till earliest 01/13/2009

With cron or task scheduler this is avoided.
Just call a script that calls up all the pending emails and sends anything older than the current time.
Depending on how frequently cron is running, every minute, every 10 minutes, etc would be the longest a user would have to wait for their email to get picked up by the system.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How do I display comments on a webpage?
Next Thread in PHP Forum Timeline: Php file upload





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC