【发布时间】:2016-03-28 22:29:36
【问题描述】:
我有一个基本的 smtp 邮件脚本,效果很好,但我唯一需要的是自定义邮件正文。我试图在脚本中定义和插入值,但是代码在某处给了我错误。我哪里做错了?
<?
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.host.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "info@host.com"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "info@host.com";
$mail->Fromname = "John Doe";
$mail->AddAddress("info@gmail.com","John Doe");
$mail->Subject = $_POST['content'];
$mail->Body = (".$arrival_date.", ".$arrival_pickup_location.", ".$arrival_dropoff_location.", ".$arrival_flight_number.", ".$arrival_fligth_time.", ".$arrival_dropoff_adress.", ".$phone_number.", ".$reservation_name.", ".$email_adress.", ".$country.", ".$additional_requests.");
$arrival_date = $_POST['arrival_date'];
$arrival_pickup_location = $_POST['arrival_pickup_location'];
$arrival_dropoff_location = $_POST['arrival_dropoff_location'];
$arrival_flight_number = $_POST['arrival_flight_number'];
$arrival_fligth_time = $_POST['arrival_fligth_time'];
$arrival_dropoff_adress = $_POST['arrival_dropoff_adress'];
$reservation_name = $_POST['reservation_name'];
$phone_number = $_POST['phone_number'];
$email_adress = $_POST['email_adress'];
$passenger = $_POST['passenger'];
$country = $_POST['country'];
$additional_requests = $_POST['additional_requests'];
if(!$mail->Send())
{
echo "Mesagge not delivered <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message sent";
?>
【问题讨论】:
-
您使用的 PHPMailer 版本非常老旧且漏洞百出。 Get the latest。此外,您的代码应基于 PHPMailer 提供的示例,而不是您找到的随机过时的示例。
标签: php smtp phpmailer html-email