As mentioned in my previous post, I've been heading up to Namibia on odd occasions for work... Although they have been rather disturbing, because (A) I don't have access to the Internet while there (other than e-mail through the exchange server) and (B) I haven't been able to get my laptop to remotely connect to my cellphone in order to access GPRS (nor get those settings to work through my phone while in Namibia).
So to bypass these little flaws in the way the security has been setup (and of course, prevent hours upon hours of utter boredom in my long day at work) I decided to write a small little PHP script to automatically deliver the content I desire to my e-mail address! The next thing I needed to do was add a little CRON job to the account and there you go! Automatic emails at specified times that allow me to view content even though I strictly don't have access to The Internet.
// your e-mail address
// the subject of your email - below will output "Slashdot articles for Tuesday, 06 Jan 2009 at 15:07:54"
$subject = 'Slashdot articles for ' . strftime("%A, %d %b %Y at %T");
// the site you want delivered to your email account - I have used slashdot below
$message = file_get_contents('http://slashdot.org');
// these headers tell your mail client how your content needs to be displayed. Don't change it!
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
// the reply address...
$headers .= "From: Slashdot E-mail sender \r\n";
// sending off your email!
if(mail($to, $subject, $message, $headers))
echo 'Mail sent';
echo 'Mail ! sent';
The easiest thing to do is to create a CRON job to send off the mail at specific times. Alternatively, you can just send it yourself (to test, of course) or get someone else to. But CRON jobs are far more reliable than people...