1
I am sending and is going as sent, but I do not receive, what can be?
<?
/Leitura dos dados de cadastro
$nome = $_POST['nome'];
$empresa = $_POST['empresa'];
$telefone = $_POST['telefone'];
$email = $_POST['email'];
$mensagem = $_POST['mensagem'];
//mensagem do email
$dados = "<br><b>Contato Recebido:</b>";
$dados .= "<br><br>Nome: ".$nome."";
$dados .= "<br><br>Empresa: ".$empresa."";
$dados .= "<br><br>Telefone: ".$telefone."";
$dados .= "<br><br>Email: ".$email."";
$dados .= "<br><br>Mensagem: ".$mensagem."<br>";
//requisicao para phpmailer
if (!class_exists("phpmailer"))
{
require("PHPMailer-5.2.6/class.phpmailer.php");
}
// Inicia a classe PHPMailer
$mail = new PHPMailer();
$mail->IsSMTP(); // Define que a mensagem será enviada via servidor SMTP
$mail->SMTPAuth = true; // Ativa a autenticação
$mail->SMTPSecure = "tls";
$mail->CharSet = 'iso-8859-1';
$mail->IsHTML(true);
$mail->Host = 'mail.meudominio.com.br'; //endereço do servidor smtp
$mail->Port = 587;
$mail->Username = "[email protected]";
$mail->Password = "senha";
$mail->From = $email;
$mail->Subject = "Contato";
$mail->MsgHTML($dados);
$address = "[email protected]";
$mail->AddAddress($address, "nome");
//envia
if($mail->Send())
{
echo "enviado";
}else{ echo "erro"; }
?>
Did you check the junk mail? The address
$address = "[email protected]";
is that correct? Are you testing on any host or locally? Add as many important details to the question.– KaduAmaral
It’s not in the junk mail. I’m testing it locally. $mail->Addaddress($address, "name"); that’s correct, already replaced by $mail->Addaddress("emaildestino");
– PHP developer
Just a question for conscience, tried to change it
<?
for this reason<?php
. Some servers see short_open_tag disabled.– Guilherme Nascimento
Enabled the debug
$mail->SMTPDebug = 3;
, to see if something happens differently?– KaduAmaral
this comment above with a bar does not exist:
/Leitura dos dados de cadastro
, in addition to the use ofshort_open_tag
is a bad practice.– Ivan Ferrer
The
from
should be an email from your domain and not passed by the user.– rray
It would be good for you to see the error in the browser console, for example in Chrome. See if there are any errors.
– Diego Souza