Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.17 KB | None | 0 0
  1. <?php
  2. require_once("phpmailer/class.phpmailer.php");    
  3.  
  4.  
  5.  $erros = "";
  6.  
  7.  if(empty($_POST['nome'])){
  8.      $erros .= "O nome deve ser preenchido.";
  9.  }
  10.  
  11.  if(empty($_POST['email']) ){
  12.       $erros .= "O E-mail deve ser preenchido.";
  13.  }else{
  14.       $email = $_POST['email'];
  15.       eregi("([\._0-9A-Za-z-]+)@([0-9A-Za-z-]+)(\.[0-9A-Za-z\.]+)",$email,$match);
  16.     if(!isset($match)){
  17.        $erros .= "O e-mail informado é inválido.";
  18.     }
  19. }
  20.  
  21. if(empty($_POST['mensagem'])){
  22.     $erros .= "A mensagem deve ser preenchida.";
  23. }
  24.  
  25. if( empty($erros) ){
  26.  
  27.     $phpmail = new PHPMailer();
  28.    
  29.    
  30.     // Define o método de envio
  31.     $phpmail->Mailer     = "smtp";  
  32.    
  33.     // Define que a mensagem poderá ter formatação HTML
  34.     $phpmail->IsHTML(true);
  35.    
  36.     //Define que a codificação do conteúdo da mensagem será utf-8
  37.     $phpmail->CharSet    = "utf-8";  
  38.    
  39.     // Define que os emails enviadas utilizarão SMTP Seguro tls
  40.     $phpmail->SMTPSecure = "tls";  
  41.    
  42.     // Define que o Host que enviará a mensagem é o Gmail
  43.     $phpmail->Host = "smtp.gmail.com";  
  44.    
  45.     //Define a porta utilizada pelo Gmail para o envio autenticado
  46.     $phpmail->Port = "587";                      
  47.    
  48.     // Deine que a mensagem utiliza método de envio autenticado
  49.     $phpmail->SMTPAuth = "true";  
  50.    
  51.     // Define o usuário do gmail autenticado responsável pelo envio
  52.     $phpmail->Username   = "ota2345";  
  53.    
  54.     // Define a senha deste usuário citado acima
  55.     $phpmail->Password = "********";  
  56.    
  57.     // Defina o email e o nome que aparecerá como remetente no cabeçalho
  58.     $phpmail->From = "ota2345@gmail.com";
  59.    
  60.     $phpmail->FromName   = "ota2345";  
  61.    
  62.  
  63.  
  64.     $phpmail->From = "ota2345@gmail.com";
  65.     $phpmail->FromName = $_POST['nome'];
  66.    
  67.     $phpmail->AddAddress("ota2345@gmail.com");
  68.     $phpmail->Subject = $_POST['assunto'];
  69.     $phpmail->Body .= "<br>Nome: ".$_POST['nome']."";
  70.     $phpmail->Body .= "<br>E-mail: ".$_POST['email']."";
  71.     $phpmail->Body .= "<br>Telefone: ".$_POST['telefone']."";
  72.     $phpmail->Body .= "<br>Assunto: ".$_POST['assunto']."";
  73.     $phpmail->Body .= "<br><br>Mensagem: ".nl2br($_POST['mensagem'])."";
  74.  
  75.     $send = $phpmail->Send();
  76.  
  77.     if($send){
  78.         echo "A Mensagem foi enviada com sucesso.";
  79.     }else{
  80.         echo "Não foi possível enviar a mensagem. Erro: " .$phpmail->ErrorInfo;
  81.     }
  82.  
  83.     }else{
  84.         echo $erros;
  85.     }
  86. ?>
  87.  
  88.  
  89. Essa e a mensagem de erro que aparece:
  90.  
  91. Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Sao_Paulo' for '-3.0/no DST' instead in C:\Webserver\Apache2.2\htdocs\email\phpmailer\class.phpmailer.php on line 1925 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Sao_Paulo' for '-3.0/no DST' instead in C:\Webserver\Apache2.2\htdocs\email\phpmailer\class.phpmailer.php on line 1925 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Sao_Paulo' for '-3.0/no DST' instead in C:\Webserver\Apache2.2\htdocs\email\phpmailer\class.phpmailer.php on line 1929 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Sao_Paulo' for '-3.0/no DST' instead in C:\Webserver\Apache2.2\htdocs\email\phpmailer\class.phpmailer.php on line 1929 A Mensagem foi enviada com sucesso.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement