Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. require_once ("PHPMailer/PHPMailerAutoload.php");
  4.  
  5. #Receber variáveis
  6. $nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
  7. $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
  8. $telefone = filter_input(INPUT_POST, 'telefone', FILTER_SANITIZE_STRING);
  9. $empresa = filter_input(INPUT_POST, 'empresa', FILTER_SANITIZE_STRING);
  10. $mensagem = filter_input(INPUT_POST, 'mensagem', FILTER_SANITIZE_STRING);
  11.  
  12. #Instanciar nova classe
  13. $mail = new PHPMailer();
  14. $mail->isSMTP();
  15.  
  16.  
  17. try {
  18.  
  19. $mail->Host = 'ssl://smtp.gmail.com:465';
  20. $mail->SMTPAuth = true;
  21. $mail->Port = 587;
  22. $mail->Username = 'seuemail@gmail.com';
  23. $mail->Password = 'SuaSenhAqui';
  24.  
  25. // Email e nome do cliente, preenchidos no formulário
  26. $mail->setFrom($email, $nome);
  27.  
  28. //Email para o qual deseja fazer o envio dos dados do formulário.
  29. $mail->addAddress('seuemail@gmail.com', 'MN Soluções em Informática');
  30.  
  31. $mail->isHTML(true);
  32. $mail->Subject = 'Pedido orçamento';
  33.  
  34. $mail->Body = "
  35. <strong>Pedido orçamento</strong><br>
  36. Nome: $nome <br>
  37. E-mail : $email <br>
  38. Telefone: $telefone <br>
  39. Empresa: $empresa <br>
  40. Mensagem: $mensagem <br>
  41. ";
  42.  
  43.  
  44. } catch (phpmailerException $e) {
  45. }
  46.  
  47.  
  48. if(!$mail->send()){
  49. echo "
  50. <script>
  51. alert('Falha no envio!');
  52. window.location.href='index.html';
  53. </script>";
  54. } else {
  55. echo "
  56. <script>
  57. alert('E-mail enviado com sucesso!');
  58. window.location.href='index.html';
  59. </script>";
  60. }
  61.  
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement