Advertisement
Guest User

enviar.php

a guest
Sep 29th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2.     require 'PHPMailer/PHPMailerAutoload.php';
  3.  
  4.     if (!empty($_POST['nome']) && !empty($_POST['email']) && !empty($_POST['numero']) && !empty($_POST['msg'])) {
  5.         $nome = $_POST['nome'];
  6.         $email = $_POST['email'];
  7.         $numero = $_POST['numero'];
  8.         $msg = $_POST['msg'];
  9.     } else {
  10.         return false;
  11.         header("Location: https://eduuamorim.com");
  12.     }
  13.    
  14.    
  15.     $Mailer = new PHPMailer();
  16.    
  17.     //Define que será usado SMTP
  18.     $Mailer->IsSMTP();
  19.    
  20.     //Enviar e-mail em HTML
  21.     $Mailer->isHTML(true);
  22.    
  23.     //Aceitar carasteres especiais
  24.     $Mailer->Charset = 'UTF-8';
  25.    
  26.     //Configurações
  27.     $Mailer->SMTPAuth = true;
  28.     $Mailer->SMTPSecure = 'ssl';
  29.    
  30.     //nome do servidor
  31.     $Mailer->Host = 'aqui fica meu host';
  32.     //Porta de saida de e-mail
  33.     $Mailer->Port = aqui minha porta;
  34.    
  35.     //Dados do e-mail de saida - autenticação
  36.     $Mailer->Username = 'suporte@eduuamorim.com';
  37.     $Mailer->Password = 'aqui minha senha :)';
  38.    
  39.     //E-mail remetente (deve ser o mesmo de quem fez a autenticação)
  40.     $Mailer->From = 'suporte@eduuamorim.com';
  41.    
  42.     //Nome do Remetente
  43.     $Mailer->FromName = 'Robot - eduuamorim'."\n";
  44.    
  45.     //Assunto da mensagem
  46.     $Mailer->Subject = 'Nova mensagem! :)';
  47.    
  48.     //Corpo da Mensagem
  49.     $Mailer->Body =
  50.     '<strong>Nome: </strong><br>'.$nome.'<br><br>
  51.    <strong>Email: </strong><br>'.$email.'<br><br>
  52.    <strong>Numero: </strong><br>'.$numero.'<br><br>
  53.    <strong>Mensagem: </strong><br>'.$msg.'<br>';
  54.    
  55.     //Corpo da mensagem em texto
  56.     $Mailer->AltBody = '';
  57.    
  58.     //Destinatario
  59.     $Mailer->AddAddress('eduuamorim1@gmail.com');
  60.    
  61.     if($Mailer->Send()){
  62.         echo ("
  63.            <script>
  64.            window.alert('Mensagem enviada com sucesso!')
  65.            window.location.href='index.php';
  66.            </script>
  67.            window.location.href='index.php';
  68.        </script>
  69.        ");
  70.     } else{
  71.         echo ("<script>
  72.        window.alert('Mensagem não enviada!')
  73.        window.location.href='index.php';
  74.        </script>");
  75.     }
  76.    
  77.     $Mailer->SMTPOptions = array(
  78.         'ssl' => array(
  79.         'verify_peer' => false,
  80.         'verify_peer_name' => false,
  81.         'allow_self_signed' => true
  82.     )
  83. );
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement