Guest User

Untitled

a guest
Nov 29th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2.  
  3. include 'Mail.php';
  4. include 'Mail/mime.php';
  5. $host = 'smtp.gmail.com';
  6. $from = 'penteado.vanessa@gmail.com';
  7. $username = 'penteado.vanessa@gmail.com';
  8. $password = 'umdoistres';
  9. $to = 'ricardo.jportela@gmail.com';
  10. $body = 'teste';
  11. $html = '<html><body>HTML version of email</body></html>';
  12. $file = 'correio.php';
  13. //$body = utf8_decode($body);
  14. $subject = utf8_decode('c\'est lavie en rose');
  15. $crlf = "\n";
  16. $recipients = $to;
  17.  
  18. $mime = new Mail_mime(array('eol' => $crlf));
  19. $mime->setTXTBody($body);
  20. $mime->setHTMLBody($html);
  21. $mime->addAttachment($file, 'text/plain');
  22. $body = $mime->get();
  23. $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
  24. $hdrs = $mime->headers($headers);
  25. $smtp = Mail::factory('smtp', array('host' => $host,
  26. 'port' => 587, // SMTP
  27. 'auth' => true, 'debug' => true,
  28. 'username' => $username,
  29. 'password' => $password)
  30. );
  31. $mail = $smtp->send($recipients, $hdrs, $body);
  32. if (PEAR::isError($mail)) {
  33. echo $mail->getMessage();
  34. } else {
  35. echo "Enviado com sucesso";
  36. }
  37. ?>
Add Comment
Please, Sign In to add comment