Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once('mail/class.phpmailer.php');
- require_once ('mail/PHPMailerAutoload.php');
- $mail = new PHPMailer();
- //indico a la clase que use SMTP
- $mail ->IsSMTP();
- //permite modo debug para ver mensajes de las cosas que van ocurriendo
- $mail ->SMTPDebug = 2;
- //Debo de hacer autenticación SMTP
- $mail ->SMTPAuth = true;
- $mail ->SMTPSecure = "ssl";
- //indico el servidor de Gmail para SMTP
- $mail ->Host = "smtp.gmail.com";
- //indico el puerto que usa Gmail
- $mail ->Port = 465;
- //indico un usuario / clave de un usuario de gmail
- $mail ->Username = "correo@gmail.com";
- $mail ->Password = "*******";
- $mail ->SetFrom('correo@gmail.com', 'Nombre completo');
- $mail ->AddReplyTo("correo@gmail.com","Nombre completo");
- $mail ->Subject = "Envío de email usando SMTP de Gmail";
- $mail ->MsgHTML("Hola que tal, esto es el cuerpo del mensaje!");
- //indico destinatario
- $address = "destino@gmail.com";
- $mail ->AddAddress($address, "Nombre completo");
- if(!$mail ->Send()) {
- echo "Error al enviar: " . $mail->ErrorInfo;
- } else {
- echo "Mensaje enviado!";
- }
- 2017-02-03 15:21:30 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 13sm9852700uac.20 - gsmtp 2017-02-03 15:21:30 CLIENT -> SERVER: EHLO localhost 2017-02-03 15:21:30 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [190.146.238.90] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-02-03 15:21:30 CLIENT -> SERVER: AUTH LOGIN 2017-02-03 15:21:30 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2017-02-03 15:21:30 CLIENT -> SERVER: ZGVhdGhzdHJva2Vjb2xvbWJpYUBnbWFpbC5jb20= 2017-02-03 15:21:30 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2017-02-03 15:21:30 CLIENT -> SERVER: MzExNTY4OTExNw== 2017-02-03 15:21:31 SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 13sm9852700uac.20 - gsmtp 2017-02-03 15:21:31 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 13sm9852700uac.20 - gsmtp 2017-02-03 15:21:31 SMTP Error: Could not authenticate. 2017-02-03 15:21:31 CLIENT -> SERVER: QUIT 2017-02-03 15:21:31 SERVER -> CLIENT: 221 2.0.0 closing connection 13sm9852700uac.20 - gsmtp 2017-02-03 15:21:31 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Error al enviar: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement