所以我正在处理这个页面:http://sitesdemo.mghospedagem.com/ivam-entregas/3/33209.html
我面临一个问题:
它使用SMTP将数据发送到电子邮件,但发送的唯一数据来自字段"Nome"answers"Email"。其他字段"Endareço de Partida"、"Endereço de Chegada"answers"Detalhes do Serviço"在提交时都是空的。
哪个php代码是:
<?php
/*
* Vinteum Desenvolvimento
* tiago@vinteum.com
*/
require_once('PHPMailer_5.2.1/class.phpmailer.php');
$nome = $_POST['nome'];
$email = $_POST['email'];
$msg = $_POST['txtDetalhes'];
$end1 = $_POST['1'];
$end2 = $_POST['txtEnderecoChegada'];
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$body .= "<h2>Pedido de orçamento para entrega</h2>";
$body .= "Nome: $nome <br>";
$body .= "E-mail: $email <br>";
$body .= "<br>";
$body .= "Mensagem: <br> $msg";
$body .= $msg;
$body .= "<br>";
$body .= "Endereço de partida: $end1 <br>";
$body .= "Endereço de chegada: $end2 <br>";
$body .= "<br>";
$body .= "----------------------------";
$body .= "<br>";
$body .= "Enviado em <b>".date("h:m:i d/m/Y")." por ".$_SERVER['REMOTE_ADDR']."</b>"; //Mostra data e Endereço IP
$body .= "<br>";
$body .= "----------------------------";
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 587; // set the SMTP server port, geralmente porta 25 ou 587
$mail->Host = "mail.xxxxxxx.com"; // SMTP server
$mail->Username = "test@xxxxxxxx.com"; // SMTP server username
$mail->Password = "xxxxxxxxx"; // SMTP server password
//$mail->IsSendmail(); // tell the class to use Sendmail
$mail->AddReplyTo($email, $nome); //Responder para
$mail->From = $email; //De E-mail
$mail->FromName = $nome; //De Nome
$to = "myemail@hotmail.com"; //Para
$mail->AddAddress($to);
$mail->Subject = "Orçamento para entrega"; //Assunto
$mail->AltBody = "Para ver essa mensagem utilize um cliente com suporte HTML!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
echo 'Mensagem enviada com sucesso.<br><a href="33209.html">VOLTAR</a><br />';
echo $end1;
//retorno (html) devolvido para o ajax caso sucesso
} catch (phpmailerException $e) {
echo $e->errorMessage(); //retorno devolvido para o ajax caso erro
}
?>
以下是HTML和Javascript代码:
http://jsbin.com/qudumegihu/1/edit
您发送数据时使用:
var urlData = "&nome=" + nome + "&email=" + email + "&msg=" + msg + "&end1=" + end1 + "&end2=" + end2;
然后尝试从不存在的$_POST
获取txtDetalhes
和txtEnderecoChegada
。您应该使用$_POST['end1']
和$_POST['end2]
。
一个小提示:尝试使用var_dump($_POST);
查看其内容。这真的很有帮助。
试试这个。在你的sendmailivam.php中。试着看看Ravan的答案。
<?php
/*
* Vinteum Desenvolvimento
* tiago@vinteum.com
*/
require_once('PHPMailer_5.2.1/class.phpmailer.php');
$nome = $_POST['nome'];
$email = $_POST['email'];
$msg = $_POST['msg'];
$end1 = $_POST['end1'];
$end2 = $_POST['end2'];