Guest User

Untitled

a guest
Feb 20th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public function sendMultiple($from,$to,$subject,$files){
  2. $eol = PHP_EOL;
  3. $separator = md5(time());
  4.  
  5. $headers = "From: "".$from."" <".$this->replyTo.">rn";
  6. $headers .= "MIME-Version: 1.0".$eol;
  7. $headers .= "Content-Type: multipart/mixed; boundary="".$separator.""".$eol.$eol;
  8.  
  9. $body = "Content-Transfer-Encoding: 7bit".$eol;
  10. $body .= "This is a MIME encoded message.".$eol;
  11. $body .= "--".$separator.$eol;
  12. $body .= "Content-Type: text/html; charset="iso-8859-1"".$eol;
  13. $body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  14. $body .= $this->getMessage().$eol;
  15. foreach ($files as $file ) {
  16. $body .= "--" . $separator . $eol;
  17. $body .= "Content-Type: application/octet-stream; name="" . $file['name'] . """ . $eol;
  18. $body .= "Content-Transfer-Encoding: base64" . $eol;
  19. $body .= "Content-Disposition: attachment" . $eol . $eol;
  20. $body .= $file['file'] . $eol;
  21. //This line is not needed, solved the issue
  22. //$body .= "--" . $separator . "--";
  23. }
  24. $mail = mail($to,$subject,$body,$headers);
  25. if($mail){
  26. return true;
  27. }
  28. return null;
  29. }
  30.  
  31. //$files is an array of this
  32. $file1 = array("name"=>"name".$name1.".pdf","file"=>chunk_split(base64_encode($pdf)));
  33. $file2 = array("name"=>"name".$name2.".pdf","file"=>chunk_split(base64_encode($pdf2)));
  34. array_push($files, $file1);
  35. array_push($files, $file2);
Add Comment
Please, Sign In to add comment