PHPMailer发送电子邮件并返回带有echo的空白页面

时间:2015-07-06 11:09:57

标签: php email xampp phpmailer

电子邮件发送正确,但随后我的提交页面上的所有内容都消失了(虽然在网址中它表示它是同一页面),但echo声明说“消息已成功发送”。

我想要表示祝贺'页面或一些不那么俗气的用户在发送验证邮件后问候用户......

我已经尝试在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);
    }
?>

2 个答案:

答案 0 :(得分:2)

如果您的请求是POST,则在发送消息后,您就会调用exit()!1&#39;回声。

else {
    echo "Message sent!1";
}
exit();

答案 1 :(得分:1)

在你的:

<form method="post">

向其添加操作,例如:

<form method="post" action="{pickaname}.php">

并创建一个名为{pickaname} .php的文件,并在插入所有数据时创建它,它会将用户重定向到祝贺页面。