连接到smtp.mail.emea.microsoftonline.com的PHPMailer问题

时间:2009-10-08 08:16:06

标签: php smtp phpmailer

尝试从运行W2K server 2003的Web服务器向smtp.mail.emea.microsoftonline.com发送电子邮件时出现以下错误

SMTP -> FROM SERVER:220 smtp.mail.emea.microsoftonline.com Microsoft ESMTP MAIL Service ready at Thu, 8 Oct 2009 01:00:53 -0700 
SMTP -> FROM SERVER: 250-smtp.mail.emea.microsoftonline.com Hello [78.109.167.122] 250-SIZE 31457280 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-AUTH 250-8BITMIME 250-BINARYMIME 250 CHUNKING 
SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type 
SMTP -> FROM SERVER:250 2.0.0 Resetting 
SMTP Error: Could not authenticate. 

有人能发现什么是错的吗?我在php.ini中也有以下设置:

[mail function]
; For Win32 only.
SMTP = smtp.mail.emea.microsoftonline.com
smtp_port = 587
; For Win32 only.
sendmail_from = enquiries@domain.com

require_once('class.phpmailer.php');

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
  $mail->Host       = "smtp.mail.emea.microsoftonline.com"; // SMTP server
  $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
  $mail->SMTPAuth   = true;                  // enable SMTP authentication
  //$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
  $mail->Port       = 587;                   // set the SMTP port for the server
  $mail->Username   = "enquiries@domain.com";  // username
  $mail->Password   = "Password";            // password
  $mail->AddReplyTo('enquiries@domain.com', 'First Last');
  $mail->AddAddress('myemail@gmail.com', 'John Doe');
  $mail->SetFrom('enquiries@domain.com', 'First Last');
  $mail->AddReplyTo('enquiries@domain.com', 'First Last');
  $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
  $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  $mail->MsgHTML(file_get_contents('examples/contents.html'));
  $mail->Send();
  echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
  echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo $e->getMessage(); //Boring error messages from anything else!
}

2 个答案:

答案 0 :(得分:0)

首先尝试这些手动步骤,看看是否可以连接:

http://technet.microsoft.com/en-us/library/aa995718(EXCHG.65).aspx

另外,这个页面: http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845%2D88d2%2D4091%2D8088%2Da6bbce0a4304&ID=665

说:FROM地址必须使用“权威”类型的SMTP域 - 这可以在Microsoft Online Administration Center的“用户 - 域”选项卡下确认。

答案 1 :(得分:0)

一个月前我遇到了同样的问题。我们的SMTPSecure引起的错误是使用ntlm。 不要忘记转发您允许发送和接收来自网络邮件的邮件服务器。 并重新检查您的帐户电子邮件和密码是否正确?