我在通过 PHPMailer 使用 SMTP 回复邮件时遇到问题。当我尝试发送邮件时
"You must provide at least one recipient email address."
我使用的以下 PHP 代码是:
require("smtp/class.phpmailer.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = '****@gmail.com';
$mail->Password = '***';
$mail->SetFrom('***@gmail.com', '***@gmail.com');
$mail->Subject = 'RE: Hello World';
$mail->Body = 'Hello World';
$mail->AddReplyTo('****@gmail.com');
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
我想知道我在配置中还缺少什么。