Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is it possible to send automatic ( hourly or more ) emails with a php script??

Posted on 2009-07-13
6
Medium Priority
?
282 Views
Last Modified: 2013-12-25
Hi,
I am fairly new to php, but have a little experiance with basic includes, and email forms etc..

is it possible to send an email to 2 or 3 addresses, every 60 mins ( or less time? )

I am running a local charity music consert, and we have set up a myspace and facebook accounts -
using a site called ping.fm - you can update you status on these other sites by sending an email to - for example: myID1234@ping.fm

So my plan is in the days leading up to the event, to regularly update. if this could be done using a php ( or other ) script, this would be brilliant.

Idealy, i would have 2 or 3 different messages, so it would cycle through them.
But it wouldnt be the end of the world if it was the same everytime - if that makes it alot simpler.

Any help, or pointers would be much apreciated.

Cheers.
Sean.
0
Comment
Question by:phatsion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Assisted Solution

by:unluckynelson
unluckynelson earned 300 total points
ID: 24840333
Some ISP's allow cron jobs on their website hostings... Log on to your website's control panel and see if you have something like that.

Otherwise start a windows schedule that simply opens your php script every two hours and leave your pc on...
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1200 total points
ID: 24840933
Almost every hosting company offers some kind of "cron" capability.  You might also find that Twitter is useful for this purpose, and you can set up automated posts to Twitter.  If you decide you want that, let me know and I will post my Twitter class for  you.

best regards, ~Ray
0
 

Author Comment

by:phatsion
ID: 24841945
Hi,,,, back again...

so after spending a while searching around for some one who hostes these for free - i found a couple.
still waiting for the best on ( i think ) to come to file.

In the mean time, i found a site called http://cronless.com

where it runs cron jobs for you at ny address.

i have been trying this, and it doesnt seem to work.

all i have done, is poped the attached code into a file, and called it email.php
uploaded it, and then set cronless to run it.

i also noticed that when i visit it in a browser, it doesnt work.

Am i missing something??

I should probably mention that the host where the file is held automaticly adds a div to the page..
should this matter??
-- also, should i be able to see the php code when i select view page source.
the page is here: http://sdr1.emenace.com/email.php

cheers
Sean.
<?
    $email = "me@hotmail.com";
    $subject = "Sent from a crontab";
    $message = "This is a message sent from a crontab";
 
    mail($email, $subject, $message);
?>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1200 total points
ID: 24842166
Here is what I would recommend.  Get a REAL hosting service, the kind you pay for.  They are very inexpensive, less than a cup of coffee per day.  I use and recommend ChiHost.com.  Tell Nick Gilbert I sent you ;-)

They have a complete control panel, and they have competent telephone and email tech support to help you set up your cron job.  

Nothing against the free services, but you often get what you pay for.  I am, therefore, not surprised that it's not working out and that there is nobody to go to for help.

You might want to try changing the code as shown below.  Obviously you need to correct the email address.  You might also want to echo the results of the mail command.  I would not be surprised if the free host disables the mail command - too easy to become an open relay for spam if you do not.
<?php // USE THE FULL HEADER, NOT THE SHORT OPEN TAG
    $email = "me@hotmail.com";
    $subject = "Sent from a crontab";
    $message = "This is a message sent from a crontab";
 
    if (!mail($email, $subject, $message)) die('MAIL FAILED');
?>

Open in new window

0
 
LVL 7

Expert Comment

by:ajkhalifa
ID: 24842270
run a php code using linux command in background...
use sleep function for that...

regards
0
 

Author Closing Comment

by:phatsion
ID: 31602854
Thanks for your help on this.
Using the cron jobs seems to work fine.
I mannaged to get free hosing, with x10hosing.com
- allthough they offer cron support, i couldnt get it to work with them.

setcronjob.com is a site that you can set cron jobs on, and they run scripts hosted with other hosts.
This was probably a long way around it, but it works, and was simple to setup.

Cheers.
S.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question