我可以通过SMTP和PHPMailer发送电子邮件,但我一直收到此错误消息。
Warning: Cannot modify header information - headers already sent by (output started at /home/admin/public_html/inc/phpmailer/class.smtp.php:181) in /home/admin/public_html/contact/index.php on line 79
发送电子邮件后,我想将用户转发到感谢页面。这是我的PHP。
if (($noName == false) AND ($noEmail == false) AND ($badEmail == false) AND ($noMessage == false)) {
header('Location: index.php?status=sent');
exit;
}
我正在使用SMTP PHPMailer类来执行此操作。
//Create a new PHPMailer instance
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "******";
$mail->Password = "******";
有关为什么会抛出此错误消息的任何建议?