PHPMailer 发送电子邮件并返回带回显的空白页
PHPMailer sending email and returning blank page with echo
电子邮件发送正确,但随后我的提交页面上的所有内容都消失了(尽管在 url 中它说它是同一页面)除了 echo 语句说 'Message sent successfully'.
我想要一个 'congratulations' 页面或一些不那么俗气的东西来向用户发送验证电子邮件后问候...
我尝试在 class.phpmailer.php 中搜索重定向功能,但一无所获。我确定它很简单,但我似乎无法找到导致此问题的原因。
<?php
require ('/config.inc.php');
require '../PHPMailer/PHPMailerAutoload.php';
if(mysqli_affected_rows($dbc) == 1){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "censored@gmail.com";
$mail->Password = "censored";
//Set who the message is to be sent from
$mail->setFrom('censored@gmail.com');
//Set an alternative reply-to address
$mail->addReplyTo('censored@gmail.com');
//Set who the message is to be sent to
$mail->addAddress($trimmed['email']);
//Set the subject line
$mail->Subject = 'PHPMailer mail() test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML('Thank you for registering at The Circle Of Pi. To activate your account,
please click on this link:\n\n' . BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a");
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!1";
}
exit();
}else {
echo '<p class=\"error\">You could not be registered due to a system error. We apologize
for any inconvenience.</p>';
}
}else{
echo '<p class = \"error\">That email address has already been registered. If you have
forgotten your password, use the link at the right to have your password sent to you</p>';
}
} else {
echo '<p class = \"error\">Please try again.</p>';
}
mysqli_close($dbc);
}
?>
如果您的请求是 POST
那么您将在 'Message sent!1' 回显后调用 exit()
。
else {
echo "Message sent!1";
}
exit();
在你的:
<form method="post">
为其添加一个动作,例如:
<form method="post" action="{pickaname}.php">
并创建一个名为 {pickaname} 的文件。php 并在插入所有数据后将其重定向到您的祝贺页面。
电子邮件发送正确,但随后我的提交页面上的所有内容都消失了(尽管在 url 中它说它是同一页面)除了 echo 语句说 'Message sent successfully'.
我想要一个 'congratulations' 页面或一些不那么俗气的东西来向用户发送验证电子邮件后问候...
我尝试在 class.phpmailer.php 中搜索重定向功能,但一无所获。我确定它很简单,但我似乎无法找到导致此问题的原因。
<?php
require ('/config.inc.php');
require '../PHPMailer/PHPMailerAutoload.php';
if(mysqli_affected_rows($dbc) == 1){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "censored@gmail.com";
$mail->Password = "censored";
//Set who the message is to be sent from
$mail->setFrom('censored@gmail.com');
//Set an alternative reply-to address
$mail->addReplyTo('censored@gmail.com');
//Set who the message is to be sent to
$mail->addAddress($trimmed['email']);
//Set the subject line
$mail->Subject = 'PHPMailer mail() test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML('Thank you for registering at The Circle Of Pi. To activate your account,
please click on this link:\n\n' . BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a");
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!1";
}
exit();
}else {
echo '<p class=\"error\">You could not be registered due to a system error. We apologize
for any inconvenience.</p>';
}
}else{
echo '<p class = \"error\">That email address has already been registered. If you have
forgotten your password, use the link at the right to have your password sent to you</p>';
}
} else {
echo '<p class = \"error\">Please try again.</p>';
}
mysqli_close($dbc);
}
?>
如果您的请求是 POST
那么您将在 'Message sent!1' 回显后调用 exit()
。
else {
echo "Message sent!1";
}
exit();
在你的:
<form method="post">
为其添加一个动作,例如:
<form method="post" action="{pickaname}.php">
并创建一个名为 {pickaname} 的文件。php 并在插入所有数据后将其重定向到您的祝贺页面。