Skip to content

Instantly share code, notes, and snippets.

@ivuorinen
Created August 6, 2011 13:36
Show Gist options
  • Save ivuorinen/1129342 to your computer and use it in GitHub Desktop.
Save ivuorinen/1129342 to your computer and use it in GitHub Desktop.
fingerpori emailer
<?php
$p = "http://www.hs.fi/fingerpori/";
$p = file_get_contents($p);
preg_match_all('/\<img id="strip([0-9]+)" src="http:\/\/www.hs.fi\/kuvat\/iso_webkuva\/([0-9]+).jpeg" align="center" border="0" alt="" title=""\>/', $p, $m);
$img = $m[0][0];
if( empty($img) ) {
preg_match_all('/\<img id="strip([0-9]+)" src="http:\/\/www.hs.fi\/kuvat\/iso_webkuva\/([0-9]+).gif" align="center" border="0" alt="" title=""\>/', $p, $m);
$img = $m[0][0];
}
//print_r($img);
if( !empty($img) ) {
$subject = 'Fingerpori: '.date("Y-m-d");
$message = '<html><head><title>'.$subject.'</title></head><body>'.$img.'</body></html>';
$to = "Your Email <example@example.com>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// $headers .= 'To: '. $to . "\r\n";
$headers .= 'From: Fingerpori Express <fingerpori@example.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
} else {
print_r($m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment