Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Agnaldo M. Goncalves

Formulario de contato no uol host

Recommended Posts

Olá Galera, alguém pode me dar um help com php. Tenho este formulário de contato e ele diz que a mensagem foi enviada com sucesso, porém não enviou. Segue aí o código PHP para os colegas. O for html é básico, só com (nome, assunto, email, mensagem, botão enviar)

 

<?php

require_once('class.phpmailer.php');


$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];




$phpmail = new PHPMailer();

$phpmail->IsSMTP(); // envia por SMTP
$phpmail->Host = "smtp.atgesso.com.br"; // SMTP servers
$phpmail->SMTPAuth = true; // Caso o servidor SMTP precise de autenticação
$phpmail->Username = "atgesso@atgesso.com.br"; // SMTP username
$phpmail->Password = "amg231160"; // SMTP password

$phpmail->IsHTML(true);

$phpmail->From = 'atgesso@atgesso.com.br';
$phpmail->FromName = $_POST['nome'];

$phpmail->AddAddress ("atgesso@atgesso.com.br");
$phpmail->Subject = $assunto;
$phpmail->Body .= "Nome: ".$_POST['nome']."";
$phpmail->Body .= "Email: ".$_POST['email']."";
$phpmail->Body .= "Assunto: ".$_POST['assunto']."";
$phpmail->Body .= "Mensagem: ".nl2br($_POST['mensagem'])."";

$send = $phpmail->Send();

if (isset($_POST['submit'])) {
if($nome && $email && $assunto && $mensagem) {
echo "<script>alert('Sua mensagem foi enviada com sucesso!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de sua página.
exit;
}
}

else {
echo "<script>alert('Preencha todos os campos!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de seu formulário
exit;
}



?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agnaldo,

 

A mensagem "Mensagem enviada com sucesso" nesse codigo refere-se somente ao envio ou nao na requisição POST.

O problema pode estar em $send = $phpmail->Send();

Verifique se consegue exibir alguma mensagem de erro dessa função e verifique os parametros na classe class.phpmailer.php se estao corretos.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ela faz o envio o e-mail, retirá-la não é um opção.

 

Depois da linha:

$phpmail = new PHPMailer();

Coloque:

$phpmail->SMTPDebug = true;

E execute novamente.

 

Ele mostrará tudo o que está acontecendo, incluindo algum erro, caso aconteça.

 

Depois posta aqui o que apareceu.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Lucas.... Então fiz alguns testes e retirei uma { , funcionou legal o email chegou, só não apareceu a mensagem: (mensagem enviada com sucesso, e não retornou para a página de contato, simplesmente ficou em uma pagina branca. segue o código

 

<?php

require_once('class.phpmailer.php');


$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
$phpmail = new PHPMailer();
$phpmail->IsSMTP(); // envia por SMTP
$phpmail->Host = "smtp.atgesso.com.br"; // SMTP servers
$phpmail->SMTPAuth = true; // Caso o servidor SMTP precise de autenticação
$phpmail->Username = "atgesso@atgesso.com.br"; // SMTP username
$phpmail->Password = ""; // SMTP password
$phpmail->IsHTML(true);
$phpmail->From = 'atgesso@atgesso.com.br';
$phpmail->FromName = $_POST['nome'];
$phpmail->AddAddress ("atgesso@atgesso.com.br");
$phpmail->Subject = $assunto;
$phpmail->Body .= "Nome: ".$_POST['nome']."";
$phpmail->Body .= "Email: ".$_POST['email']."";
$phpmail->Body .= "Assunto: ".$_POST['assunto']."";
$phpmail->Body .= "Mensagem: ".nl2br($_POST['mensagem'])."";

$send = $phpmail->Send();
$phpmail->SMTPDebug = true;

if (isset($_POST['enviar']))
if($nome && $email && $assunto && $mensagem) {
echo "<script>alert('Sua mensagem foi enviada com sucesso!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de sua página.
exit;
}

else {
echo "<script>alert('Preencha todos os campos!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de seu formulário
exit;
}

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Lucas, desculpa aí a gafe....coloquei o código onde vc pediu daí retortou issso:

 

2014-02-07 18:24:42 Connection: opening 2014-02-07 18:24:42 Connection: opened 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "220 a2-smithers3.uhserver.com ESMTP " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "220 a2-smithers3.uhserver.com ESMTP " 2014-02-07 18:24:42 SERVER -> CLIENT: 220 a2-smithers3.uhserver.com ESMTP 2014-02-07 18:24:42 CLIENT -> SERVER: EHLO www.atgesso.com.br 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-a2-smithers3.uhserver.com " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-PIPELINING " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-SIZE 41943040 " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-VRFY " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-ETRN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-AUTH=LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250-8BITMIME " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME " 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME " 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250 DSN " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN " 2014-02-07 18:24:42 SERVER -> CLIENT: 250-a2-smithers3.uhserver.com 250-PIPELINING 250-SIZE 41943040 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN LOGIN PLAIN 250-AUTH=LOGIN PLAIN LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 2014-02-07 18:24:42 CLIENT -> SERVER: AUTH LOGIN 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "334 VXNlcm5hbWU6 " 2014-02-07 18:24:42 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2014-02-07 18:24:42 CLIENT -> SERVER: YXRnZXNzb0BhdGdlc3NvLmNvbS5icg== 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "334 UGFzc3dvcmQ6 " 2014-02-07 18:24:42 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2014-02-07 18:24:42 CLIENT -> SERVER: YW1nMTk4MQ== 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "235 2.7.0 Authentication successful " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "235 2.7.0 Authentication successful " 2014-02-07 18:24:42 SERVER -> CLIENT: 235 2.7.0 Authentication successful 2014-02-07 18:24:42 CLIENT -> SERVER: MAIL FROM: 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250 2.1.0 Ok " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250 2.1.0 Ok " 2014-02-07 18:24:42 SERVER -> CLIENT: 250 2.1.0 Ok 2014-02-07 18:24:42 CLIENT -> SERVER: RCPT TO: 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250 2.1.5 Ok " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250 2.1.5 Ok " 2014-02-07 18:24:42 SERVER -> CLIENT: 250 2.1.5 Ok 2014-02-07 18:24:42 CLIENT -> SERVER: DATA 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "354 End data with . " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "354 End data with . " 2014-02-07 18:24:42 SERVER -> CLIENT: 354 End data with . 2014-02-07 18:24:42 CLIENT -> SERVER: Date: Fri, 7 Feb 2014 16:24:42 -0200 2014-02-07 18:24:42 CLIENT -> SERVER: Return-Path: 2014-02-07 18:24:42 CLIENT -> SERVER: To: atgesso@atgesso.com.br 2014-02-07 18:24:42 CLIENT -> SERVER: From: agnaldo 2014-02-07 18:24:42 CLIENT -> SERVER: Subject: somente teste 2014-02-07 18:24:42 CLIENT -> SERVER: Message-ID: <95e5c3cb8c4c6bc4aaa07ef34ab18602@www.atgesso.com.br> 2014-02-07 18:24:42 CLIENT -> SERVER: X-Priority: 3 2014-02-07 18:24:42 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/) 2014-02-07 18:24:42 CLIENT -> SERVER: MIME-Version: 1.0 2014-02-07 18:24:42 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1 2014-02-07 18:24:42 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 2014-02-07 18:24:42 CLIENT -> SERVER: 2014-02-07 18:24:42 CLIENT -> SERVER: Nome: agnaldoEmail: goncalvesagnaldo@gmail.comAssunto: somente testeMensagem: testes 2014-02-07 18:24:42 CLIENT -> SERVER: 2014-02-07 18:24:42 CLIENT -> SERVER: . 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "250 2.0.0 Ok: queued as 7C0A3E000086 " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "250 2.0.0 Ok: queued as 7C0A3E000086 " 2014-02-07 18:24:42 SERVER -> CLIENT: 250 2.0.0 Ok: queued as 7C0A3E000086 2014-02-07 18:24:42 CLIENT -> SERVER: QUIT 2014-02-07 18:24:42 SMTP -> get_lines(): $data was "" 2014-02-07 18:24:42 SMTP -> get_lines(): $str is "221 2.0.0 Bye " 2014-02-07 18:24:42 SMTP -> get_lines(): $data is "221 2.0.0 Bye " 2014-02-07 18:24:42 SERVER -> CLIENT: 221 2.0.0 Bye 2014-02-07 18:24:42 Connection: closed



Lucas, as mensagens estão chegando, só a mensansagem de enviada com sucesso e redirecionamento da página é que não está, Pode estar faltando alguma chave....



segue aí o cógigo que inseri:

 

<?php

require_once('class.phpmailer.php');


$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
$phpmail = new PHPMailer();
$phpmail->SMTPDebug = true;
$phpmail->IsSMTP(); // envia por SMTP
$phpmail->Host = "smtp.atgesso.com.br"; // SMTP servers
$phpmail->SMTPAuth = true; // Caso o servidor SMTP precise de autenticação
$phpmail->Username = "atgesso@atgesso.com.br"; // SMTP username
$phpmail->Password = ""; // SMTP password
$phpmail->IsHTML(true);
$phpmail->From = 'atgesso@atgesso.com.br';
$phpmail->FromName = $_POST['nome'];
$phpmail->AddAddress ("atgesso@atgesso.com.br");
$phpmail->Subject = $assunto;
$phpmail->Body .= "Nome: ".$_POST['nome']."";
$phpmail->Body .= "Email: ".$_POST['email']."";
$phpmail->Body .= "Assunto: ".$_POST['assunto']."";
$phpmail->Body .= "Mensagem: ".nl2br($_POST['mensagem'])."";

$send = $phpmail->Send();


if (isset($_POST['enviar']))
if($nome && $email && $assunto && $mensagem) {
echo "<script>alert('Sua mensagem foi enviada com sucesso!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de sua página.
exit;
}

else {
echo "<script>alert('Preencha todos os campos!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de seu formulário
exit;
}

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Lucas....Segui o seu caminho das pedras e consegui resolver, está tudo funcionando ok.... Grato pela ajuda parceiro, fico lhe devendo esta..... segue o cócigo resolvido:

 

$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;
}


echo $erros;


echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de sua página.
exit;



echo "<script>alert('Preencha todos os campos!');</script>";
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de seu formulário
exit;


?>



Segue o código mais organizado:

 

<?php

require_once('class.phpmailer.php');


$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
$phpmail = new PHPMailer();
$phpmail->IsSMTP(); // envia por SMTP
$phpmail->Host = "smtp.atgesso.com.br"; // SMTP servers
$phpmail->SMTPAuth = true; // Caso o servidor SMTP precise de autenticação
$phpmail->Username = "atgesso@atgesso.com.br"; // SMTP username
$phpmail->Password = ""; // SMTP password
$phpmail->IsHTML(true);
$phpmail->From = 'atgesso@atgesso.com.br';
$phpmail->FromName = $_POST['nome'];
$phpmail->AddAddress ("atgesso@atgesso.com.br");
$phpmail->Subject = $assunto;
$phpmail->Body .= "Nome: ".$_POST['nome']."";
$phpmail->Body .= "Email: ".$_POST['email']."";
$phpmail->Body .= "Assunto: ".$_POST['assunto']."";
$phpmail->Body .= "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;
}

echo $erros;
echo "<script>window.location = 'http://www.atgesso.com.br/contato.html';</script>"; //Altere aqui para o endereço de sua página.
exit;

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.