如何使用phpmailer发送联系人表单 电子邮件: 消息:
AddAddress是一个方法,而不是属性如何使用phpmailer发送联系人表单 电子邮件: 消息:,php,email,Php,Email,AddAddress是一个方法,而不是属性 <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; require("PHPMailerAutoload.php"); require "class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // turn on S
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require("PHPMailerAutoload.php");
require "class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = "smtp.gmail.com";
$mail->Username = "myemail@gmail.com"; // SMTP username
$mail->Password = "*************"; // SMTP password
$mail->AddAddress=$email;
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
应该是:
$mail->AddAddress=$email;
AddAddress是一个方法,而不是属性
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require("PHPMailerAutoload.php");
require "class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = "smtp.gmail.com";
$mail->Username = "myemail@gmail.com"; // SMTP username
$mail->Password = "*************"; // SMTP password
$mail->AddAddress=$email;
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
应该是:
$mail->AddAddress=$email;
addAddress
是PHPMailer类中的一个函数,因此您需要将所需的电子邮件作为参数传递。addAddress
是PHPMailer类中的一个函数,因此您需要将所需的电子邮件作为参数传递。感谢您的评论,但仍需向中至少添加一个receipentRefer。检查var_dump(PHPMailer::validateAddress($email))的输出代码>以排除错误。哪一个版本的PHP?谢谢你的评论,但至少要添加一个receipentRefer到。检查var_dump(PHPMailer::validateAddress($email))的输出代码>以排除错误。哪个版本的PHP?