Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("phpmailer/class.phpmailer.php");
- $erros = "";
- if(empty($_POST['nome'])){
- $erros .= "O nome deve ser preenchido.";
- }
- if(empty($_POST['email']) ){
- $erros .= "O E-mail deve ser preenchido.";
- }else{
- $email = $_POST['email'];
- eregi("([\._0-9A-Za-z-]+)@([0-9A-Za-z-]+)(\.[0-9A-Za-z\.]+)",$email,$match);
- if(!isset($match)){
- $erros .= "O e-mail informado é inválido.";
- }
- }
- if(empty($_POST['mensagem'])){
- $erros .= "A mensagem deve ser preenchida.";
- }
- if( empty($erros) ){
- $phpmail = new PHPMailer();
- // Define o método de envio
- $phpmail->Mailer = "smtp";
- // Define que a mensagem poderá ter formatação HTML
- $phpmail->IsHTML(true);
- //Define que a codificação do conteúdo da mensagem será utf-8
- $phpmail->CharSet = "utf-8";
- // Define que os emails enviadas utilizarão SMTP Seguro tls
- $phpmail->SMTPSecure = "tls";
- // Define que o Host que enviará a mensagem é o Gmail
- $phpmail->Host = "smtp.gmail.com";
- //Define a porta utilizada pelo Gmail para o envio autenticado
- $phpmail->Port = "587";
- // Deine que a mensagem utiliza método de envio autenticado
- $phpmail->SMTPAuth = "true";
- // Define o usuário do gmail autenticado responsável pelo envio
- $phpmail->Username = "ota2345";
- // Define a senha deste usuário citado acima
- $phpmail->Password = "********";
- // Defina o email e o nome que aparecerá como remetente no cabeçalho
- $phpmail->From = "ota2345@gmail.com";
- $phpmail->FromName = "ota2345";
- $phpmail->From = "ota2345@gmail.com";
- $phpmail->FromName = $_POST['nome'];
- $phpmail->AddAddress("ota2345@gmail.com");
- $phpmail->Subject = $_POST['assunto'];
- $phpmail->Body .= "<br>Nome: ".$_POST['nome']."";
- $phpmail->Body .= "<br>E-mail: ".$_POST['email']."";
- $phpmail->Body .= "<br>Telefone: ".$_POST['telefone']."";
- $phpmail->Body .= "<br>Assunto: ".$_POST['assunto']."";
- $phpmail->Body .= "<br><br>Mensagem: ".nl2br($_POST['mensagem'])."";
- $send = $phpmail->Send();
- if($send){
- echo "A Mensagem foi enviada com sucesso.";
- }else{
- echo "Não foi possível enviar a mensagem. Erro: " .$phpmail->ErrorInfo;
- }
- }else{
- echo $erros;
- }
- ?>
- Essa e a mensagem de erro que aparece:
- 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