当我尝试使用PHPMailer类发送电子邮件时,我收到此错误:邮件程序错误:邮件正文为空:
<?php
include("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "rsb20.rhostbh.com";
$mail->Port = 465;
$mail->Username = "jobserreker+furrtexlab.com";
$mail->Password = "12345678a";
$mail->From = "jobserreker@furrtexlab.com";
$mail->FromName = "Job Seeker";
$mail->Subject = $_GET['subject'];
$mail->MsgHTML($_GET['msg']);
$mail->AddAddress($_GET['to'],"name to");
$mail->IsHTML(false);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "Message sent!";
}
?>
Run Code Online (Sandbox Code Playgroud)
正如Gerald Versluis所说,由于你将IsHTML()设置为false,你必须使用 - > Body属性来设置邮件的实际主体.
$mail->Body = $_GET['msg'];
Run Code Online (Sandbox Code Playgroud)
您还应该使用POST而不是GET来提交导致执行操作的内容.