

Generlanie szukam czegoś prostego do wysyłania PDF z pliku
function send_mail($emailaddress, $fromaddress, $emailsubject, $body, $attachments=false) { $eol="\r\n"; # Common Headers $headers .= 'From: MyName<'.$fromaddress.'>'.$eol; $headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol; $headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol; // these two to set reply address $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; # Boundry for marking the split & Multitype Headers $headers .= 'MIME-Version: 1.0'.$eol; $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol; $msg = ""; if ($attachments !== false) { { { # File for Attachment $f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode(); # Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol; $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol; } } } # Setup for text OR html $msg .= "Content-Type: multipart/alternative".$eol; # Text Version $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; # HTML Version $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= $body.$eol.$eol; # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection. # SEND THE EMAIL } # To Email Address $emailaddress="to@address.com"; # From Email Address $fromaddress = "from@address.com"; # Message Subject $emailsubject="This is a test mail with some attachments"; # Use relative paths to the attachments ); # Message Body $body="This is a message with <b>".count($attachments)."</b> attachments and maybe some <i>HTML</i>!"; send_mail($emailaddress, $fromaddress, $emailsubject, $body, $attachments);