php mail with multiple atachements -


i'd send mail 2 atachements using php base libraries.

so far use this

while($donnee = $reponse->fetch()){ $mime_boundary = md5(uniqid(time()));  $message = "message text";  $to = $donnee["mail"];  //define subject of email  $subject = "title";;  //create boundary string. must unique  //so use md5 algorithm generate random hash  $random_hash = md5(date('r', time()));    // $header = "from : sender-mail \r\nreply-to: sender-mail \r\n"; $header .= "mime-version:1.0\r\n"; $header .= "content-type:multipart/mixed; boundary=\"{$mime_boundary}\"\r\n\r\n";  // message $header .= "--{$mime_boundary}\r\n"; $header .= "content-type:text/html; charset=\"iso-8859-1\"\r\n"; $header .= "content-transfer-encoding:7bit\r\n\r\n"; $header .= "<html><head><style type=\"text/css\">body { font:10pt arial; }</style></head><body>". str_replace("\r", "", str_replace("\n", "<br />", $message)) ."</body></html>\r\n\r\n";  // attachment $attachments = array("../fichier/downloadable/cv.docx","../fichier/downloadable/resume.pdf"); $attachmentnames = array("covering_letter_anthony_pifarré.docx","cv_anthony_pifarré.pdf"); ($i = 0; $i < count($attachments); $i++) {     if (!base64_decode($attachments[$i], true))         $attachments[$i] = base64_encode($attachments[$i]);     else         $attachments[$i] = str_replace("\r", "", str_replace("\n", "", str_replace(" ", "+", $attachments[$i])));      $header .= "--{$mime_boundary}\r\n";     $header .= "content-type:application/octet-stream; name=\"{$attachmentnames[$i]}\"\r\n";     $header .= "content-transfer-encoding:binary\r\n";     $header .= "content-disposition:attachment; filename=\"{$attachmentnames[$i]}\"\r\n";     $header .= "{$attachments[$i]}\r\n\r\n"; }  //send email  mail( $to, $subject, "", $header );  $requ = 'update mailing_list set already_sent = 1 id = "'.$donnee["id"].'"'; //$bdd->exec($requ);  echo "<br/>"."sent : ".$donnee["mail"]; $counter++;} 

this send me email correct text message, sender un name ok. atachements empty. got 2 files right names weights 0ko. when try write $attachements[$i] ig got text , not nothing.

any idea?


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -