Zyphering Posted April 22, 2008 Share Posted April 22, 2008 Hi Is there a way to make the PHP Server send email at a Specific Time of the Day automatically. Like Mail an End of the Day Report at 7:00 Everyday. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/ Share on other sites More sharing options...
DeanWhitehouse Posted April 22, 2008 Share Posted April 22, 2008 can you not use the if(); with a variable $time and then set this using PHP time? Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-524146 Share on other sites More sharing options...
litebearer Posted April 22, 2008 Share Posted April 22, 2008 you can use a cron to do that Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-524148 Share on other sites More sharing options...
Zyphering Posted April 24, 2008 Author Share Posted April 24, 2008 can you not use the if(); with a variable $time and then set this using PHP time? I can do that but that means I will need a computer to keep open the webpage and auto refresh it at a fixed intervels so the script gets called again and again till it meets the time constraints. ( I think) any other way to do this ? you can use a cron to do that I am not running PHP on a UNIX server and my knowledge of unix is very weak. Any other alternative ? Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526595 Share on other sites More sharing options...
dptr1988 Posted April 24, 2008 Share Posted April 24, 2008 If you have enough visitors on your website, you can use them as a 'cron' daemon! Each time somebody loads a page, check if it's 07:00 and if it is, you can send the email. It's not guranteed to send at the right time, but if you get a lot of traffic, it would be pretty accurate. But this is a last resort for people that don't have any type of cron system. Always use cron if you can. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526598 Share on other sites More sharing options...
Zyphering Posted April 25, 2008 Author Share Posted April 25, 2008 If you have enough visitors on your website, you can use them as a 'cron' daemon! Each time somebody loads a page, check if it's 07:00 and if it is, you can send the email. It's not guranteed to send at the right time, but if you get a lot of traffic, it would be pretty accurate. But this is a last resort for people that don't have any type of cron system. Always use cron if you can. Hmm that is the problem. On my website 30 Employees will be working 8 hours a day from 8 A.M. to 5 P.M. After 5 P.M. nobody will be even touching or logging into the website. So no traffic at all. I guess I will have to ask a manager to manually send the end of the day report each day by logging in and clicking some button. I don't think you can trigger a php script without user interaction. (is that the bottom line) ? Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526783 Share on other sites More sharing options...
DarkWater Posted April 25, 2008 Share Posted April 25, 2008 Yeah, that's correct, Zyphering. >_> Why aren't you hosting your site on a *nix system, if you don't mind my asking? Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526785 Share on other sites More sharing options...
Zyphering Posted April 25, 2008 Author Share Posted April 25, 2008 Yeah, that's correct, Zyphering. >_> Why aren't you hosting your site on a *nix system, if you don't mind my asking? Well currently the Project is in testing phase. And I created a small testing server for me on Windows XP (lol) with PHP, MYSQL, IIS. After a few weeks of testing the project (on 4-5 users) it will move to the Server House. To serve more users (around 30). Then maintaining and keeping the server up won't me my problem. They might use *nix if they feel like, totally depends on them. My knowlege of *nix is weak, never got time to interact with it. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526789 Share on other sites More sharing options...
DarkWater Posted April 25, 2008 Share Posted April 25, 2008 Lol, windows. Sorry, I had to get that out there. D: Try to get them to put it on a unix or linux system. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526793 Share on other sites More sharing options...
blackcell Posted April 25, 2008 Share Posted April 25, 2008 If you want to stick with the system you have just create a page called RUN.php or something. Create a js onload function that is recursive on a timed interval of like 10 seconds. Within that page put the single script to check if time is the desired time and then if so send the email. You can leave this page open on any system anywhere and it will work. I work with large scale business software that is written in VB? and it does crap like this and they get paid bukoo bucks for it. So its like a service on the system you run it on. Its not to shabby if you have a server that is running all the time. Just open the page on it and leave it running. Matter fact I think I will try this on a program I am writing now. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526797 Share on other sites More sharing options...
litebearer Posted April 25, 2008 Share Posted April 25, 2008 if it is on a windows system you can use a scheduling program to automatically invoke ie to run the proper script at the appointed time Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526799 Share on other sites More sharing options...
Zyphering Posted April 25, 2008 Author Share Posted April 25, 2008 If you want to stick with the system you have just create a page called RUN.php or something. Create a js onload function that is recursive on a timed interval of like 10 seconds. Within that page put the single script to check if time is the desired time and then if so send the email. You can leave this page open on any system anywhere and it will work. I work with large scale business software that is written in VB? and it does crap like this and they get paid bukoo bucks for it. So its like a service on the system you run it on. Its not to shabby if you have a server that is running all the time. Just open the page on it and leave it running. Matter fact I think I will try this on a program I am writing now. Yup that was what I told earlier. Keepeing a page open and making it Auto-Refresh will solve the problem. But then there are reliability issues if the page closes. This code will help your program. You won't need a recursive js onload function. (I think) Header refresh will take care of it. Just code the function to check time and send email. <?php check_if_Time_is_Greater_And_Send_Email($timeToSendEmail); header('Refresh: 5'); ?> if it is on a windows system you can use a scheduling program to automatically invoke ie to run the proper script at the appointed time Nice Idea I can use a windows scheduling agent to launch the webpage and it can check weather the time is greater then the Required time to send the report. Cool never thought of it. I will try this, if I get stuck I will message you. Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526852 Share on other sites More sharing options...
cunoodle2 Posted April 25, 2008 Share Posted April 25, 2008 I have a solution for you with this that will NOT require you to use a cron job (and probably not even an IF statement). 1. Create a page with a really strange name that no one could ever guess and never ever tell anyone that page name. For example. end_of_day_report_987654321asdfg.php Then download a FREE alarm clock program for your home personal computer. Something like this here... http://mac.softpedia.com/get/Utilities/Alarm-Clock-Pro.shtml That one is for a mac but you can find something anywhere by doing a google search. Then trigger an alarm to go off on your computer every day (M-F) at 7pm and when the alarm goes off have it open up that particular page which will then generate report and e-mail it out. Let me know your thoughts on this one. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-526861 Share on other sites More sharing options...
topcodedeveloper Posted September 27, 2013 Share Posted September 27, 2013 with out having to user cron job, this would do that same thing. <?php header('Refresh: 5'); $timeis=date('Y:m:d h:i:s a', time()); echo $timeis; $timer=date('Y:m:d h:i:s a', time()); $mytimer="2013:09:27 07:20:00 am"; if ($timer>=$mytimer) { echo "<br><p>It works, email will now be sent."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-1451403 Share on other sites More sharing options...
topcodedeveloper Posted September 27, 2013 Share Posted September 27, 2013 Here's another way to have it loop through an array: <?php header('Refresh: 5'); $setup=array("2013:09:27 07:52:00 am", "2013:09:27 07:53:00 am"); $arrlength=count($setup); $timeis=date('Y:m:d h:i:s a', time()); $timem=date('Y:m:d'); echo $timeis; $timer=date('Y:m:d h:i:s a', time()); for($x=0;$x<$arrlength;$x++) $mytimer=$setup[$x]; if ($timer>=$mytimer) { echo "<br><p>It works, email will now be sent."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-1451405 Share on other sites More sharing options...
Ch0cu3r Posted September 27, 2013 Share Posted September 27, 2013 You do realise this thread is about 5 years old. Quote Link to comment https://forums.phpfreaks.com/topic/102364-send-email-at-specific-time-automatically/#findComment-1451407 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.