Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 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. use PHPMailer\PHPMailer\PHPMailer;
  7. use PHPMailer\PHPMailer\Exception;
  8.  
  9. if(!isset($_POST['email']))
  10. die("N&atilde;o recebi nenhum par&acitc;metro. Por favor volte ao formulario.html antes");
  11.  
  12. $emailsender = "contato@anjosdosorriso.com.br";
  13.  
  14. /* Verifica qual é o sistema operacional do servidor para ajustar o cabeçalho de forma correta. Não alterar */
  15. if(PHP_OS == "Linux") $quebra_linha = "\n"; //Se for Linux
  16. elseif(PHP_OS == "WINNT") $quebra_linha = "\r\n"; // Se for Windows
  17. else die("Este script nao esta preparado para funcionar com o sistema operacional de seu servidor");
  18.  
  19. // Passando os dados obtidos pelo formulário para as variáveis abaixo
  20. $nomeremetente = $_POST['nome'];
  21. $empresa = $_POST['empresa'];
  22. $emaildestinatario = 'isaias@anjosdosorriso.com.br';
  23. $email = $_POST['email'];
  24. $phone = $_POST['phone'];
  25. $descricao = $_POST['descricao'];
  26. $servicos = $_POST['servicos'];
  27.  
  28. /* Montando a mensagem a ser enviada no corpo do e-mail. */
  29. $mensagemHTML = '<h1>Solicitação Orçamento</h1>'
  30. . '<p><strong>Nome: </strong> '.$nomeremetente.'</p>'
  31. . '<p><strong>E-mail: </strong> '.$email.'</p>'
  32. . '<p><strong>Telefone: </strong> '.$phone.'</p>'
  33. . '<p><strong>Serviços: </strong> '.$servicos.'</p>'
  34. . '<p><strong>Mensagem: </strong> '.$descricao.'</p>'
  35. . '<hr>';
  36.  
  37. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  38.  
  39. try {
  40. //Server settings
  41. $mail->SMTPDebug = 1; // Enable verbose debug output
  42. $mail->isSMTP(); // Set mailer to use SMTP
  43. $mail->Port = 587; // TCP port to connect to
  44. $mail->Host = 'smtp.anjosdosorriso.com.br'; // Specify main and backup SMTP servers
  45.  
  46. $mail->SMTPAuth = true; // Enable SMTP authentication
  47. $mail->Username = 'dev@anjosdosorriso.com.br'; // SMTP username
  48. $mail->Password = 'Loca20$$18'; // SMTP password
  49. //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  50. $mail->CharSet = "UTF-8";
  51.  
  52.  
  53. //Recipients
  54. $mail->setFrom('dev@anjosdosorriso.com.br', 'Anjos do Sorriso');
  55. $mail->addAddress('filipe.santos_@live.com', 'Filipe Santos'); // Add a recipient
  56. //$mail->addReplyTo('contato@anjosdosorriso.com.br', 'Anjos do Sorriso');
  57. //$mail->addCC('cc@example.com');
  58. //$mail->addBCC('filipe.santos_@live.com');
  59.  
  60. //Content
  61. $mail->isHTML(true); // Set email format to HTML
  62. $mail->Subject = '[WEBSITE] Cadastro Newsletter';
  63. $mail->Body = $mensagemHTML;
  64. //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  65.  
  66. $mail->send();
  67.  
  68. print_r($mail);
  69.  
  70. } catch (Exception $e) {
  71. print $e;
  72. // print '<script type="text/javascript">' .
  73. // 'setTimeout(function(){' .
  74. // 'window.location.href="' . $_SERVER['REQUEST_URI'] . '?send=false";'.
  75. // '}, 1000);'.
  76. // '</script>';
  77. return;
  78. }
  79.  
  80. /* Mostrando na tela as informações enviadas por e-mail */
  81. // print '<script type="text/javascript">' .
  82. // 'setTimeout(function(){' .
  83. // 'window.location.href="' . $_SERVER['REQUEST_URI'] . '/?send=true";'.
  84. // '}, 1000);'.
  85. // '</script>';
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement