电子邮件发送后收到错误

时间:2018-05-30 05:59:47

标签: php phpmailer

我已创建联系表单以联系用户admin。我使用PHP Mailer将邮件发送到管理员电子邮件ID。它工作,我也收到电子邮件,但当我提交表格提醒表格提交成功然后我面临一些错误。我不明白发生了什么错误。请帮我。我提供以下联系表格和错误。

这是我的backend_contact.php页面编码。

<?php       
    include 'phpmailer/PHPMailerAutoload.php';

    if(isset($_POST['send'])){

        $name = $_POST['name'];
        $email = $_POST['email'];
        $msg = $_POST['message'];

        $full_message='<table width="650" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">    
        <tr>
            <td width="584" bgcolor="#FFFFFF"><span class="style3">Parekh Website Contact Form</span></td>
        </tr>
        <tr>
            <td height="45" valign="middle" bgcolor="#FFFFFF">
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <tr>
                        <td width="59%">
                            <p class="style3"><strong>Name :</strong>'.$name.'</p>
                            <p class="style3"><strong>Email ID: </strong>  '.$email.'</p>                   
                            <p class="style3"><strong>Message:</strong> '.$msg.'</p> 
                        </td>
                    </tr>
                </table>
            </td>
        </tr>     

        <tr>
            <td height="68" bgcolor="#FFFFFF" >
                <p>With warm regards, </p>
                <p>Administrator <br />
                    Parekh</p></td>
            </tr>
        </table>';

        if(empty($name)){
            echo "<script type='text/javascript'>
                alert('Please Enter Your Name.')
                window.location = '../contact.php';
            </script>";
        }
        elseif(empty($email)){          
            echo "<script type='text/javascript'>
                alert('Please Enter Your Email Id.')
                window.location = '../contact.php';
            </script>";
        }
        elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)){
            echo "<script type='text/javascript'>
                alert('Please Enter Valid Email.')
                window.location = '../contact.php';
            </script>";
        }
        elseif(empty($msg)){
            echo "<script type='text/javascript'>
                alert('Please Enter Your Message.')
                window.location = '../contact.php';
            </script>";
        }
        else{
            $mail = new PHPMailer;
            $mail->isSMTP();
            $mail->SMTPDebug = 2;
            $mail->Debugoutput = 'html';
            $mail->Host = 'smtp.sendgrid.net';
            $mail->Port = 587;
            $mail->SMTPSecure = 'tls';
            $mail->SMTPAuth = true;
            $mail->Username = "xxxx.in";
            $mail->Password = "xxxx";
            $mail->setFrom('xxx@xxx.in','xxxx');
            $mail->addAddress('xxxx@xxx.in', 'xxxx');            
            $mail->Subject = 'Website Contact Form';
            $mail->msgHTML($full_message);          
            $mail->AltBody = 'Website Contact Form';            
            if ($mail->send()){
                echo "<script>
                        alert('Form Submitted successfully.');
                        window.location.href='../contact.php';
                    </script>";
            }
        }   
    }   
?>

并且,表单提交后面临错误。

SERVER -> CLIENT: 220 SG ESMTP service ready at ismtpd0008p1hnd1.sendgrid.net
CLIENT -> SERVER: EHLO xxx.in
SERVER -> CLIENT: 250-smtp.sendgrid.net250-8BITMIME250-PIPELINING250-SIZE 31457280250-STARTTLS250-AUTH PLAIN LOGIN250 AUTH=PLAIN LOGIN
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 Begin TLS negotiation now
CLIENT -> SERVER: EHLO xxx.in
SERVER -> CLIENT: 250-smtp.sendgrid.net250-8BITMIME250-PIPELINING250-SIZE 31457280250-STARTTLS250-AUTH PLAIN LOGIN250 AUTH=PLAIN LOGIN
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: cGlzcGwuaW4=
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: UEBzc3cwcmRwaXM=
SERVER -> CLIENT: 235 Authentication successful
CLIENT -> SERVER: MAIL FROM:<xxx@xxxx.in>
SERVER -> CLIENT: 250 Sender address accepted
CLIENT -> SERVER: RCPT TO:<xxxxxx@gmail.com>
SERVER -> CLIENT: 250 Recipient address accepted
CLIENT -> SERVER: DATA
SERVER -> CLIENT: 354 Continue
CLIENT -> SERVER: Date: Wed, 30 May 2018 11:03:19 +0530
CLIENT -> SERVER: To: xxxx <xxxxx@gmail.com>
CLIENT -> SERVER: From: xxxx <info@pispl.in>
CLIENT -> SERVER: Subject: Website Contact Form
CLIENT -> SERVER: Message-ID: <6de67638bea8977cdb1aacaadc8d90d4@xxx.in>
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.13 (https://github.com/PHPMailer/PHPMailer)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: multipart/alternative;
CLIENT -> SERVER: boundary="b1_6de67638bea8977cdb1aacaadc8d90d4"
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
CLIENT -> SERVER: 
CLIENT -> SERVER: This is a multi-part message in MIME format.
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_6de67638bea8977cdb1aacaadc8d90d4
CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
CLIENT -> SERVER: 
CLIENT -> SERVER: Website Contact Form
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_6de67638bea8977cdb1aacaadc8d90d4
CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
CLIENT -> SERVER: 
CLIENT -> SERVER: <table width="650" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">   
CLIENT -> SERVER: <tr>
CLIENT -> SERVER: <td width="584" bgcolor="#FFFFFF"><span class="style3">Parekh Website Contact Form</span></td>
CLIENT -> SERVER: </tr>
CLIENT -> SERVER: <tr>
CLIENT -> SERVER: <td height="45" valign="middle" bgcolor="#FFFFFF">
CLIENT -> SERVER: <table border="0" cellspacing="0" cellpadding="0" width="100%">
CLIENT -> SERVER: <tr>
CLIENT -> SERVER: <td width="59%">
CLIENT -> SERVER: <p class="style3"><strong>Name :</strong>xxxx</p>
CLIENT -> SERVER: <p class="style3"><strong>Email ID: </strong> xxxxx@gmail.com</p> 
CLIENT -> SERVER: <p class="style3"><strong>Message:</strong> hii test </p> 
CLIENT -> SERVER: </td>
CLIENT -> SERVER: </tr>
CLIENT -> SERVER: </table>
CLIENT -> SERVER: </td>
CLIENT -> SERVER: </tr> 
CLIENT -> SERVER: 
CLIENT -> SERVER: <tr>
CLIENT -> SERVER: <td height="68" bgcolor="#FFFFFF" >
CLIENT -> SERVER: <p>With warm regards, </p>
CLIENT -> SERVER: <p>Administrator <br />
CLIENT -> SERVER: xxxxxx</p></td>
CLIENT -> SERVER: </tr>
CLIENT -> SERVER: </table>
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_6de67638bea8977cdb1aacaadc8d90d4--
CLIENT -> SERVER: 
CLIENT -> SERVER: .
SERVER -> CLIENT: 250 Ok: queued as -ZsWIWQ7SXeYJz-SHpzbkg
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 See you later

2 个答案:

答案 0 :(得分:1)

没有任何错误,即所有Mailer Debug代码,因为您已将其设置为

$mail->SMTPDebug = 2;

您应该将Mailer调试设置为关闭,因此不会显示调试代码。

使用下面的代码。

$mail->SMTPDebug = 0

答案 1 :(得分:0)

尝试将window.location.href替换为除此之外的window.location,我没有看到任何问题,也关闭了phpmailer调试。