Author Topic: Send email at Specific Time ? Automatically  (Read 935 times)

0 Members and 1 Guest are viewing this topic.

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Send email at Specific Time ? Automatically
« on: April 22, 2008, 01:26:11 PM »
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.

Offline Blade280891

  • Addict
  • Posts: 2,496
  • Gender: Male
  • Mr.Grumpypants
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #1 on: April 22, 2008, 01:37:58 PM »
can you not use the if(); with a variable $time
and then set this using PHP time?
Read the rules http://www.phpfreaks.com/page/rules-and-terms-of-service#toc_forum_guidelines

Quote
99.9% of my replies are correct, the other 0.1% means you asked the wrong question

Offline litebearer

  • Addict
  • Posts: 2,534
    • View Profile
    • http://nstoia.com
Re: Send email at Specific Time ? Automatically
« Reply #2 on: April 22, 2008, 01:40:26 PM »
you can use a cron to do that
Quote
all the brothers were valiant!
The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #3 on: April 24, 2008, 06:32:06 PM »
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 ?

Offline dptr1988

  • Enthusiast
  • Posts: 370
  • Gender: Male
    • View Profile
    • http://www.phpcodinghelp.com
Re: Send email at Specific Time ? Automatically
« Reply #4 on: April 24, 2008, 06:36:08 PM »
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.
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacoder.com/RentACoder/Default.asp?txtFromURL=AId_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #5 on: April 24, 2008, 11:06:42 PM »
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) ?

Offline DarkWater

  • Freak!
  • Posts: 6,158
  • Gender: Male
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #6 on: April 24, 2008, 11:08:10 PM »
Yeah, that's correct, Zyphering. >_>  Why aren't you hosting your site on a *nix system, if you don't mind my asking?
Info:Apache 2.2.4 | PHP 6.0.0-dev, PHP 5.2.4 | Ubuntu 8.04 | Age: 16 | Coding PHP and CSS+(X)HTML: 5-6 years | Feel free to PM me if you need help!
Αν χρειάζεσαι ένας μεταφραστής, μπορέις να μου μιλάς.  Μιλώ καλά.
Quote from: Crayon Violent
If you ask for a banana, would you expect someone to hand you an orange? Or a fork?  No you wouldn't, because you asked for a banana, and you expect them to understand that a banana is not an orange or a fork.  It's the same principle.

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #7 on: April 24, 2008, 11:14:14 PM »
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.

Offline DarkWater

  • Freak!
  • Posts: 6,158
  • Gender: Male
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #8 on: April 24, 2008, 11:17:48 PM »
Lol, windows.  Sorry, I had to get that out there.  D:  Try to get them to put it on a unix or linux system.
Info:Apache 2.2.4 | PHP 6.0.0-dev, PHP 5.2.4 | Ubuntu 8.04 | Age: 16 | Coding PHP and CSS+(X)HTML: 5-6 years | Feel free to PM me if you need help!
Αν χρειάζεσαι ένας μεταφραστής, μπορέις να μου μιλάς.  Μιλώ καλά.
Quote from: Crayon Violent
If you ask for a banana, would you expect someone to hand you an orange? Or a fork?  No you wouldn't, because you asked for a banana, and you expect them to understand that a banana is not an orange or a fork.  It's the same principle.

Offline blackcell

  • Enthusiast
  • Posts: 423
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #9 on: April 24, 2008, 11:23:15 PM »
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.
The beginning...crave, hunger, entertain....incept
OEF Afghanistan Vet 2006-2007 and 2009-2010
There is always a hard way to do something easy...

Offline litebearer

  • Addict
  • Posts: 2,534
    • View Profile
    • http://nstoia.com
Re: Send email at Specific Time ? Automatically
« Reply #10 on: April 24, 2008, 11:27:45 PM »
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
all the brothers were valiant!
The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #11 on: April 25, 2008, 01:36:45 AM »
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.

Code: [Select]
<?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.

Offline cunoodle2

  • Devotee
  • Posts: 811
  • Yup Yup
    • View Profile
Re: Send email at Specific Time ? Automatically
« Reply #12 on: April 25, 2008, 02:11:34 AM »
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.
If the code was working and now it's not, something changed. Did you change any code?
yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.