我已经设置了一个php程序,其中包含一个phpmailer发送,可以在我的本地机器上正常运行,但它不会在send()命令之后运行任何代码。
以下是本地工作正常的代码,几乎与在我的联系页面上正常工作的代码相同:
$subject = "";
$subject .= "Welcome to Your Strength Coach!";
$body = "";
$body .= "
Hi " . $nameFirst . ",
<br><br>
Welcome to <a href=\"https://www.yourstrengthcoach.com/\">Your Strength Coach</a>!
<br><br>
Thank you for signing up. We look forward to being a part of your health and fitness journey.
<br><br>
Be sure to check out the Getting Started section on the Your Account page to get answers to the most common questions we receive. If you have any that aren't answered there, please feel free to email us at anytime. You can reach us at support@yourstrengthcoach.com.
<br><br>
Thanks again,<br>
Brian Gwaltney, Creator
<br><br>
Be sure to check us out on <a href=\"https://www.facebook.com/YourStrengthCoach1/\">Facebook</a>, <a href=\"https://www.instagram.com/yourstrengthcoach/\">Instagram</a>, and <a href=\"https://www.pinterest.com/yourstrengthcoach/\">Pinterest</a>!";
$mail = new PHPMailer;
$mail->IsSMTP(); // Use SMTP
$mail->Host = "smtp.servergrove.com"; // Sets SMTP server
$mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$mail->SMTPAuth = TRUE; // enable SMTP authentication
$mail->SMTPSecure = "tls"; //Secure conection
$mail->Port = 587; // set the SMTP port
$mail->Username = '**'; // SMTP account username
$mail->Password = '**'; // SMTP account password
$mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$mail->CharSet = 'UTF-8';
$mail->Encoding = '8bit';
$mail->Subject = 'New Message from Your Strength Coach Contact Page';
$mail->ContentType = 'text/html; charset=utf-8\r\n';
$mail->From = 'info@yourstrengthcoach.com';
$mail->FromName = 'Your Strength Coach';
$mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$mail->AddAddress($email); // To:
$mail->isHTML(TRUE);
$mail->Body = $body;
$mail->Send();
$nextPage = '../profile';
LoginWithCookie($nextPage,$user);
而不是继续创建cookie后重定向的登录功能,我得到了这个:
2017-05-28 19:40:03服务器 - &gt;客户:220 smtp2.servergrove.com ESMTP Exim 4.72 Sun,2017年5月28日19:40:03 +0000 2017-05-28 19:40:03客户 - &GT;服务器:EHLO www.yourstrengthcoach.com 2017-05-28 19:40:03服务器 - &gt;客户:250-smtp2.servergrove.com您好www.yourstrengthcoach.com [38.89.161.133] 250-SIZE 52428800 250流水 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP 2017-05-28 19:40:03客户 - &gt;服务器:STARTTLS 2017-05-28 19:40:03服务器 - &gt; 客户:220 TLS继续2017-28 19:40:03客户 - &gt;服务器:EHLO www.yourstrengthcoach.com 2017-05-28 19:40:03服务器 - &gt;客户: 250-smtp2.servergrove.com您好www.yourstrengthcoach.com [38.89.161.133] 250-SIZE 52428800 250流水 250-AUTH PLAIN LOGIN 250 HELP 2017-05-28 19:40:03客户 - &gt;服务器:AUTH LOGIN 2017-05-28 19:40:03服务器 - &gt; 客户:334 VXNlcm5hbWU6 2017-05-28 19:40:03客户 - &gt;服务器: aW5mb0B5b3Vyc3RyZW5ndGhjb2FjaC5jb20 = 2017-05-28 19:40:03 SERVER - &gt; 客户:334 UGFzc3dvcmQ6 2017-05-28 19:40:03客户 - &gt;服务器: MEJpZ1NlY3JldCk = 2017-05-28 19:40:04服务器 - &gt;客户:235 身份验证成功2017-05-28 19:40:04客户端 - &gt;服务员:邮件 来自:2017-05-28 19:40:04服务器 - &gt; 客户:250 OK 2017-05-28 19:40:04客户 - &gt;服务器:RCPT TO:2017-05-28 19:40:04服务器 - &gt;客户:250 接受2017-05-28 19:40:04客户 - &gt;服务器:DATA 2017-05-28 19:40:04服务器 - &gt;客户:354输入消息,以&#34;结尾。&#34;在...上 行单独2017-28 19:40:04客户 - &gt;服务器:日期:5月28日星期日 2017 19:40:03 +0000 2017-05-28 19:40:04客户 - &gt;服务器:致: brian@rosevillesc.com 2017-05-28 19:40:04客户 - &gt;服务员:来自:你的 力量教练2017-05-28 19:40:04客户 - &GT;服务器:主题:你的力量教练的新消息联系页面2017-05-28 19:40:04客户 - &gt;服务器:消息ID: 2017-05-28 19:40:04客户 - &gt;服务器:X-Priority:1 2017-05-28 19:40:04客户 - &gt; SERVER:X-Mailer:PHPMailer 5.2.23 (https://github.com/PHPMailer/PHPMailer)2017-05-28 19:40:04客户 - &gt; 服务器:MIME版本:1.0 2017-05-28 19:40:04客户端 - &gt;服务器: 内容类型:text / html; charset = UTF-8 2017-05-28 19:40:04客户 - &gt; 服务器:2017-05-28 19:40:04客户 - &gt;服务器:2017-05-28 19:40:04客户 - &gt;服务员:Hi brian,2017-05-28 19:40:04客户 - &gt; 服务器:
2017-05-28 19:40:04客户 - &gt;服务员:欢迎来到您的力量教练! 2017-05-28 19:40:04客户 - &gt;服务员:
2017-05-28 19:40:04客户 - &gt;服务器:感谢您注册。我们期望 成为您健康和健身之旅的一部分。 2017年5月28日 19:40:04客户 - &gt;服务器:
2017-05-28 19:40:04客户 - &gt; 服务器:请务必查看您的“入门”部分 帐户页面可以获得我们收到的最常见问题的答案。 如果您有任何答案,请随时发送电子邮件 我们在任何时候。您可以通过support@yourstrengthcoach.com与我们联系。 2017-05-28 19:40:04客户 - &gt;服务员:
2017-05-28 19:40:04客户 - &gt;服务员:再次感谢,
2017-05-28 19:40:04客户 - &gt;服务器:Brian Gwaltney,创作者2017-05-28 19:40:04客户 - &gt;服务器:
2017-05-28 19:40:04客户 - &gt; 服务员:一定要在Facebook,Instagram和Facebook上查看我们 Pinterest! 2017-05-28 19:40:04客户 - &gt;服务器:2017-05-28 19:40:04客户 - &gt; 服务器:。 2017-05-28 19:40:04服务器 - &gt;客户:250好 id = 1dF42m-00015y-51 2017-05-28 19:40:04客户 - &gt;服务器:退出 2017-05-28 19:40:04服务器 - &gt;客户:221 smtp2.servergrove.com 关闭连接
任何想法出了什么问题?
答案 0 :(得分:1)
邮件部分没有任何问题。这一行:
2017-05-28 19:40:04 SERVER -> CLIENT: 250 OK id=1dF42m-00015y-51
表示您的邮件服务器已成功接受该邮件。
可能存在的问题是,在您生成输出(即调试日志)之后发出的任何标头都不会被发送,因为那时已经太晚了。如果关闭调试输出(SMTPDebug = 0
),重定向将能够正常工作。