Solved

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

Posted on 2009-07-13
6
271 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 100 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 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 110

Accepted Solution

by:
Ray Paseur earned 400 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to dynamically set the form action using jQuery.

739 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