Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用phpmailer发送联系人表单 电子邮件: 消息:_Php_Email - Fatal编程技术网

如何使用phpmailer发送联系人表单 电子邮件: 消息:

如何使用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

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是一个方法,而不是属性

<?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?