Guest User

Untitled

a guest
Feb 18th, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailerPHPMailerPHPMailer;
  4. use PHPMailerPHPMailerException;
  5.  
  6. //Load composer's autoloader
  7. require 'vendor/autoload.php';
  8.  
  9. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  10. try {
  11. //Server settings
  12. $mail->SMTPDebug = 2; // Enable verbose debug output
  13. $mail->isSMTP(); // Set mailer to use SMTP
  14. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  15. $mail->SMTPAuth = true; // Enable SMTP authentication
  16. $mail->Username = 'meuemail@gmail.com'; // SMTP username
  17. $mail->Password = 'minhasenha123'; // SMTP password
  18. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  19. $mail->Port = 587; // TCP port to connect to
  20.  
  21. //Recipients
  22. $mail->setFrom('meuemail@gmail.com', 'Mailer');
  23. $mail->addAddress('meuemail@gmail.com', 'Joe User'); // Add a recipient
  24.  
  25. //Content
  26. $mail->isHTML(true); // Set email format to HTML
  27. $mail->Subject = 'Here is the subject';
  28. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  29. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  30.  
  31. $mail->send();
  32. echo 'Message has been sent';
  33. } catch (Exception $e) {
  34. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  35. }
  36. ?>
  37.  
  38. 2018-02-18 16:22:22 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP k2sm16846924qtk.60 - gsmtp<br> 2018-02-18 16:22:22 CLIENT -> SERVER: EHLO localhost<br> 2018-02-18 16:22:23 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2804:431:b705:30c:3c68:a6f0:fd8e:b468]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8<br> 2018-02-18 16:22:23 CLIENT -> SERVER: STARTTLS<br> 2018-02-18 16:22:23 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS<br> SMTP Error: Could not connect to SMTP host.<br> 2018-02-18 16:22:23 CLIENT -> SERVER: QUIT<br> 2018-02-18 16:22:23 <br> 2018-02-18 16:22:23 <br> SMTP Error: Could not connect to SMTP host.<br> Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
Add Comment
Please, Sign In to add comment