".$eol; $headers .= "Reply-To: ".$from." <".$fromaddress.">".$eol; $headers .= "Return-Path: ".$from." <".$fromaddress.">".$eol; // these two to set reply address $headers .= "Message-ID: <".time(). "-" . md5($fromaddress . $emailaddress) . "@" . $_SERVER['SERVER_NAME'] . ">" .$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters $headers .= 'MIME-Version: 1.0'.$eol; if (!empty($attachment)) { //send multipart message # Boundry for marking the split & Multitype Headers $mime_boundary=md5(time()); $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol; $contentType = "text/plain"; if ($html) { $contentType = "text/html"; } # Body $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$contentType."; charset=\"".$encoding."\"".$eol; $msg .= "Content-Disposition: inline".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $body.$eol.$eol; # File for Attachment $f_name = $filename; $f_contents=$attachment;//Encode The Data For Transition using base64_encode(); # Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: \"" . $fileType . "\"" .$eol; $msg .= "Content-Transfer-Encoding: BASE64".$eol; $msg .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol; # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection. } else { $headers .= "Content-Type: text/plain; charset=\"".$encoding."\"".$eol; $headers .= "Content-Disposition: inline".$eol; $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $body.$eol.$eol; } //ini_set(sendmail_from, 'from@me.com'); // the INI lines are to force the From Address to be used ! ini_set(sendmail_from, $fromaddress); //needed to hopefully get by spam filters. $success = mail($emailaddress, $emailsubject, $msg, $headers); ini_restore(sendmail_from); return $success; } if (SendMail($To, $From, $From, $Subject, $Message, false, $Attachement, $FileName, $FileType)) echo "Mail Ok"; else echo "Mail Error"; ?>