Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $nombre = $_POST['nombre'];
  2. $email = $_POST['email'];
  3. $mensaje = $_POST['mensaje'];
  4.  
  5. require_once('lib/phpmailer/class.phpmailer.php');
  6. $mail = new PHPMailer();
  7.  
  8. //indico a la clase que use SMTP
  9. $mail->isSMTP();
  10.  
  11. $mail->CharSet = "UTF-8";
  12.  
  13. //permite modo debug para ver mensajes de las cosas que van ocurriendo
  14. $mail->SMTPDebug = 2;
  15.  
  16. //Debo de hacer autenticación SMTP
  17. $mail->SMTPAuth = true;
  18. $mail->SMTPSecure = 'ssl';
  19.  
  20. //indico el servidor de Gmail para SMTP
  21. $mail->Host = "smtp.gmail.com";
  22.  
  23. //indico el puerto que usa Gmail
  24. $mail->Port = 465;
  25.  
  26. //indico un usuario / clave de un usuario de gmail
  27. $mail->Username = "email@gmail.com";
  28. $mail->Password = "pass";
  29. $mail->setFrom('xxx@gmail.com', 'Restaurante ');
  30. $mail->addReplyTo($email, $nombre);
  31. $mail->Subject = "Nuevo mensaje recibido .";
  32. $mail->msgHTML($mensaje);
  33.  
  34. //indico destinatario
  35. //$address = "xxx@gmail.com";
  36. $address = "xxx@gmail.com";
  37. $mail->addAddress($address, "Restaurante");
  38.  
  39. if(!$mail->send()) {
  40. echo "Error al enviar: ". $mail->ErrorInfo;
  41. } else {
  42. echo "Mensaje enviado!";
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement