Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Core\Email;
  4.  
  5. class Email {
  6. private $mail;
  7.  
  8. public function __construct(){
  9. require_once BASE_DIR."vendor/phpmailer/phpmailer/PHPMailerAutoload.php";
  10.  
  11. $mail = new \PHPMailer;
  12.  
  13. $mail->SMTPDebug = 3;
  14. //Enable verbose debug output
  15.  
  16. $mail->isSMTP();
  17. // Set mailer to use SMTP
  18. $mail->Host = 'smtp.gmail.com';
  19. // Specify main and backup SMTP servers
  20. $mail->SMTPAuth = true;
  21. // Enable SMTP authentication
  22. $mail->Username = 'meuemail@gmail.com';
  23. // SMTP username
  24. $mail->Password = '********';
  25. // SMTP password
  26. $mail->SMTPSecure = 'ssl';
  27. // Enable TLS encryption, `ssl` also accepted
  28. $mail->Port = 587;
  29. // TCP port to connect to
  30.  
  31. $mail->setFrom('meuemail@gmail.com', 'Rafael');
  32. $mail->addAddress('emailremetente@hotmail.com', 'rafael');
  33. // Add a recipient
  34. $mail->addAddress('emailremetente@hotmail.com');
  35. // Name is optional
  36. $mail->addReplyTo('meuemail@gmail.com', 'Rafael Dimas');
  37. // $mail->addCC('cc@example.com');
  38. // $mail->addBCC('bcc@example.com');
  39.  
  40. // $mail->addAttachment('/var/tmp/file.tar.gz');
  41. // Add attachments
  42. // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');
  43. // Optional name
  44. $mail->isHTML(true);
  45. // Set email format to HTML
  46.  
  47. $mail->Subject = 'Here is the subject';
  48. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  49. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  50.  
  51. if(!$mail->send()) {
  52. echo 'Message could not be sent.';
  53. echo 'Mailer Error: ' . $mail->ErrorInfo;
  54. }
  55. else {
  56. echo 'Message has been sent';
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement