Get the Front Page of the B'ham News emailed to your iPhone or iPad - From You to You

Yesterday I saw a post on Twitter from Wade Kwon that referenced the front page of the local paper, The Birmingham News. I clicked on the first link and was shocked to see a beautiful, full color image of todays front page on my iPad! I could pinch to zoom and read all the text and it looked really great. I immediately started searching the newspapers website to find a digital subscription so I could read the whole paper... Sadly, there is (as of this writing) no such thing. I really want the whole paper, but, enjoyed the front page on my iPad too much to walk away :) I decided to write a PHP script to email me the front page every day.
Here is the Tweet that was the Genesis of this project, click on the first link.
This displays great on any iDevice, but, won't display on others (I have tested Android, and Outlook) the reason is the Front Page is in PDF format and Safari has a built in viewer for PDF that will allow it to display in email.
At this point I am going to switch to telling you how you can implement this yourself. Requirements are a Windows machine that stays on all the time (your home server) and a Gmail account.
Step 1: Download EasyPHP for Windows (all of the versions they host will work, I used 5.3.4.0) here.
Step 2: Download the PHP and other project files here.
Step 3: Install EasyPHP and then dump all the files from the NewsFrontPagePHP.zip file into the www directory. (If you have 64 bit Windows this will be in C:\Program Files (x86)\EasyPHP-5.3.4.0\www If you have 32 bit, you won't have the (x86) part)
Step 4: Right click the EasyPHP icon in the tray and select configuration, then PHP. You will need to locate ;extension=php_openssl.dll and remove the ; in front to allow the ssl conection to Gmail <- Updated You must do this step!
Step 5: In the www directory, open the file dailynews.php with notepad and change the part near the top so that it contains your gmail address and your gmail password $MygmailAddress = 'yourreal@gmail.com';
$MygmailPassword = 'password';
Step 6: Double click the file dailynews.bat to send yourself an email with todays Front Page! (caution: this file closes all instances of Internet Explorer after running our script, so if your reading this in IE, it will be closed) - If you received the email proceed to the next step to automate this!
Step 7: Use Task Scheduler to launch dailynews.bat every morning at the time you choose! Task Scheduler sees .bat files as programs, so your basically launching a program every day. If you have issues with Task Scheduler here is a nice guide.
Here is the PHP code:
<?php
// SteveNorris.com Front Page Script - You *Must* put your full gmail address: 'bob@gmail.com' and 'yourrealpassword' in for it to work!
$MygmailAddress = 'XXXXXXXXXX@gmail.com';
$MygmailPassword = 'XXXXXXXXXX';
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
require_once 'MAIL5.php'; // This calls XPertMailer which makes it so you can use gmail so easy - this file must be in the same directory!
mb_internal_encoding("utf-8");
$m = new MAIL5;
$m->From($MygmailAddress, 'My Home Server', 'UTF-8');
$m->AddTo($MygmailAddress, 'Recipient', 'UTF-8');
$m->Subject('Todays News', 'UTF-8');
date_default_timezone_set('America/Chicago'); // In case you forgot to set timezone in PHP, I assume your in Central time, this will assure correct day
$wday = date("l");
$wday = strtolower($wday);
echo $wday;
$m->Html("<embed src=\"http://www.al.com/birminghamnews/pageone/$wday.pdf#toolbar=0&navpanes=0&scrollbar=0\" width=\"794\" height=\"1750\">");
$c = $m->Connect('smtp.gmail.com', 465, $MygmailAddress, $MygmailPassword, 'tls') or die(print_r($m->Result));
echo $m->Send($c) ? ' Mail sent !' : 'Error !';
$m->Disconnect();
?>
// SteveNorris.com is in no way affiliated with AL.com or The Birmingham News - This script is given freely you may use it how you like, please include my credit
There you go! Hope you enjoy this, please leave comments on your success.
Comments