因此,我正在使用并成功地使用PHPmailer发送电子邮件,但是一旦电子邮件发送,我不确定将页面重定向回到您来自哪个页面的消息,这些消息可能会发送消息?PHP邮件查询
<?php
if (isset($_POST['hp']) && $_POST['hp'] && $_POST['hp'] != '') {
}
else {
require 'c:\php\includes\PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ''; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->Port =;
$mail->From = '';
$mail->FromName = '';
foreach ($members as $user) {
$mail->addAddress($user->user_email);
}
foreach ($committee as $user) {
$mail->AddCC($user->user_email);
}
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST["Subject"];
$mail->Body = $_POST["contentfield"];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
}
?>
我已将所有的细节都拿出来了,原因很明显。
<?php
header('Location: /path/to/page');
exit;
你只是问如何重定向用户从PHP代码?所有这些邮件代码(你说是否按预期工作)是否真的与这有关? – David
嗨,是的问题是,当我包括一个重定向,如标题(位置)它会停止发送出于某种原因的电子邮件。 – user3725879
在这种情况下,听起来好像有*在某处出错。你能显示导致这个错误的代码吗?当你调试时,它在哪里失败? – David