Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. require 'PHPMailerAutoload.php';
  2.  
  3. $mail = new PHPMailer;
  4.  
  5. //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  6.  
  7. $mail->isSMTP();                                      // Set mailer to use SMTP
  8. $mail->Host = 'smtp1.example.com';  // Specify main and backup SMTP servers
  9. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  10. $mail->Username = 'user@example.com';                 // SMTP username
  11. $mail->Password = 'secret';                           // SMTP password
  12. $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  13. $mail->Port = 587;                                    // TCP port to connect to
  14.  
  15. $nombre = $_POST['nombre'];
  16. $mail = $_POST['email'];
  17. $telefono = $_POST['telefono'];
  18. $asunto = $_POST['asunto'];
  19. $empresa = $_POST['mensaje'];
  20.  
  21. $mail->setFrom($nombre, $mail);
  22. $mail->isHTML(true);                                  // Set email format to HTML
  23.  
  24. $asunto = 'Mensaje de mi sitio web';
  25. $mensaje = "Este mensaje fue enviado por " . $nombre . ",\r\n";
  26. $mensaje .= "Su e-mail es: " . $mail . " \r\n";
  27. $mensaje .= "Asunto: " . $asunto . " \r\n";
  28. $mensaje .= "Teléfono: " . $telefono . " \r\n";
  29. $mensaje .= "Mensaje: " . $_POST['mensaje'] . " \r\n";
  30. $mensaje .= "Enviado el " . date('d/m/Y', time());
  31.  
  32. $mail->Subject = $asunto;
  33. $mail->Body    = $mensaje;
  34.  
  35. if(!$mail->send()) {
  36.     echo 'Message could not be sent.';
  37.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  38. } else {
  39. echo "<script type='text/javascript'>alert('Tu mensaje ha sido enviado exitosamente');</script>";
  40. echo "<script type='text/javascript'>window.location.href='http://www.agroeducacion.com/postgrado';</script>";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement