我试图用这个代码发送电子邮件(SMTP_HOST等在配置中定义的常量,它们都被定义,它使用端口587):
$txt = strip_tags(str_replace(array("<br>","<br\>","<br \>"),"\n",$this->_params['message']));
// some irrelevant code here (saves record)
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->Port = SMTP_PORT;
$mail->SMTPAuth = true;
$mail->Username = $mail->From = SMTP_USER;
$mail->Password = SMTP_PASS;
$mail->addReplyTo($this->_params['email'], $this->_params['name']);
$mail->From = MAIL_FROM;
$mail->FromName = MAIL_FROM_NAME;
$mail->addAddress(MAIL_TO);
$mail->Body = str_replace("\n","<br/>\n",$this->_params['message']);
$mail->AltBody = $txt;
$mail->Subject = MAIL_SUBJECT.$this->_params['subject'];
$mail->isHTML (true);
$mail->SMTPDebug = 3;
$ok = $mail->send();
随着PHPMailer的版本5.2.7。
我收到调试信息(我****任何私人数据):
2014-07-04 13:57:38 Connection: opening
2014-07-04 13:57:38 Connection: opened
2014-07-04 13:57:38 SERVER -> CLIENT: 220 **** ESMTP Exim 4.82 Fri, 04 Jul 2014 15:57:38 +0200
2014-07-04 13:57:38 CLIENT -> SERVER: EHLO ****
2014-07-04 13:57:38 SERVER -> CLIENT: 250-**** Hello **** [****]
250-SIZE 20971520
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
2014-07-04 13:57:38 CLIENT -> SERVER: AUTH LOGIN
2014-07-04 13:57:38 SERVER -> CLIENT: 334 ****
2014-07-04 13:57:38 CLIENT -> SERVER: ****
2014-07-04 13:57:38 SERVER -> CLIENT: 334 ****
2014-07-04 13:57:38 CLIENT -> SERVER: ****
2014-07-04 13:57:38 SERVER -> CLIENT: 235 Authentication succeeded
2014-07-04 13:57:38 CLIENT -> SERVER: MAIL FROM:<****>
2014-07-04 13:57:38 SERVER -> CLIENT: 250 OK
2014-07-04 13:57:38 CLIENT -> SERVER: RCPT TO:<****>
2014-07-04 13:57:38 SERVER -> CLIENT: 250 Accepted
2014-07-04 13:57:38 CLIENT -> SERVER: DATA
2014-07-04 13:57:38 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2014-07-04 13:57:38 CLIENT -> SERVER: Date: Fri, 4 Jul 2014 15:57:38 +0200
2014-07-04 13:57:38 CLIENT -> SERVER: To: ****
2014-07-04 13:57:38 CLIENT -> SERVER: From: Automat SNC <****>
2014-07-04 13:57:38 CLIENT -> SERVER: Reply-To: **** <****@koszmail.pl>
2014-07-04 13:57:38 CLIENT -> SERVER: Subject: ****: Contact-form Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: Message-ID: <ff1fbff844bf01ff24f5575e9e362ef1@****>
2014-07-04 13:57:38 CLIENT -> SERVER: X-Priority: 3
2014-07-04 13:57:38 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.7(https://github.com/PHPMailer/PHPMailer/)
2014-07-04 13:57:38 CLIENT -> SERVER: MIME-Version: 1.0
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: multipart/alternative;
2014-07-04 13:57:38 CLIENT -> SERVER: boundary="b1_ff1fbff844bf01ff24f5575e9e362ef1"
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: test test test test
2014-07-04 13:57:38 CLIENT -> SERVER: test
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: <br/>
2014-07-04 13:57:38 CLIENT -> SERVER: test test test test
2014-07-04 13:57:38 CLIENT -> SERVER: <br/>
2014-07-04 13:57:38 CLIENT -> SERVER: test
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1--
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: .
2014-07-04 13:57:48 SERVER -> CLIENT:
2014-07-04 13:57:48 SMTP ERROR: DATA END command failed:
SMTP Error: data not accepted.
2014-07-04 13:57:48 CLIENT -> SERVER: QUIT
2014-07-04 13:57:49 SERVER -> CLIENT: 250 OK id=1X33ze-0007GO-Nc
2014-07-04 13:57:49 SMTP ERROR: QUIT command failed: 250 OK id=1X33ze-0007GO-Nc
2014-07-04 13:57:49 Connection: closed
有人可以给我一个提示,什么都可以错在这里?