<?php if (strtoupper(substr(PHP_OS,0,3)=='WIN')): $eol="rn"; elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')): $eol="r"; else: $eol="n"; endif; ?>
<?php $f_name="../../letters/".$letter; $handle=fopen($f_name, 'rb'); $f_contents=fread($handle, filesize($f_name)); $f_contents=chunk_split(base64_encode($f_contents)); $f_type=filetype($f_name); fclose($handle); $emailaddress="him@her.com"; $emailsubject="Heres An Email with a PDF".date("Y/m/d H:i:s"); ob_start(); require("emailbody.php"); $body=ob_get_contents(); ob_end_clean();
$headers .= 'From: Jonny <jon@genius.com>'.$eol; $headers .= 'Reply-To: Jonny <jon@genius.com>'.$eol; $headers .= 'Return-Path: Jonny <jon@genius.com>'.$eol; $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; $mime_boundary=md5(time()); $headers .= 'MIME-Version: 1.0'.$eol; $headers .= "Content-Type: multipart/related; boundary="".$mime_boundary.""".$eol; $msg = "";
$msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: application/pdf; name="".$letter.""".$eol; $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment; filename="".$letter.""".$eol.$eol; $msg .= $f_contents.$eol.$eol; $msg .= "Content-Type: multipart/alternative".$eol;
$msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= "This is a multi-part message in MIME format.".$eol; $msg .= "If you are reading this, please update your email-reading-software.".$eol; $msg .= "+ + Text Only Email from Genius Jon + +".$eol.$eol;
$msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= $body.$eol.$eol;
$msg .= "--".$mime_boundary."--".$eol.$eol; ini_set(sendmail_from,'from@me.com'); mail($emailaddress, $emailsubject, $msg, $headers); ini_restore(sendmail_from); ?>
|