Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. require 'PHPMailer/src/Exception.php';
  3. require 'PHPMailer/src/PHPMailer.php';
  4. require 'PHPMailer/src/SMTP.php';
  5.  
  6. $mail = new PHPMailer();
  7. $mail->isSMTP();
  8. $mail->SMTPDebug = 4;
  9. //$mail->SMTPSecure = 'tls';
  10. //$mail->Host = 'tls://smtp.gmail.com';
  11. //$mail->Port = 587;
  12. $mail->SMTPSecure = 'ssl';
  13. $mail->Host = 'smtp.gmail.com';
  14. $mail->Port = 465;
  15. $mail->SMTPAuth = true;
  16. $mail->Username = "seu-email@gmail.com";
  17. $mail->Password = "abcdefhijklmnopq"; //nao e a senha do email e sim senha de App com 16 caracteres
  18. //para gerar senha de App siga ao painel de controle da sua conta google e:
  19. //Segurança > Como fazer Login > Senhas de app
  20. //basta gerar a senha e colocar aqui no atributo Password
  21. $mail->setFrom('seu-email@gmail.com', 'Seu nome e sobrenome');
  22. $mail->addAddress('email-destinatario@gmail.com', 'Nome e Sobrenome');
  23. $mail->Subject = 'PHPMailer GMail SMTP test';
  24. $mail->msgHTML("Olá mundo");
  25. $mail->AltBody = 'This is a plain-text message body';
  26. if (!$mail->send()) {
  27. echo "Deu ruim: " . $mail->ErrorInfo;
  28. } else {
  29. echo "Mensagem enviada!";
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement