2013-06-26 154 views
1

我想使用Exchange身份驗證發送郵件與迅捷郵件。但是,我似乎無法弄清楚爲什麼它不起作用。使用交換身份驗證發送電子郵件與快捷郵件

<?php 
require_once("./application/helpers/swift/swift_required.php"); 
$transport = 
Swift_SmtpTransport::newInstance("31.149.66.10", 25) 
    ->setUsername("username") 
    ->setPassword('password') 
    ->setEncryption("tls"); 
$mailer = Swift_Mailer::newInstance($transport); 
$message = Swift_Message::newInstance("onderwerp") 
->setFrom(array("[email protected]")) 
->setTo(array("[email protected]")) 
->setBody("Body van het bericht"); 
var_dump($mailer->send($message)); 
?> 

這給我的錯誤:Uncaught exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "nieuwsbrief" using 0 possible authenticators'.

服務器配置爲使用TLS和基本身份驗證(僅在啓動TLS後提供基本的身份驗證)。

我看到一些人使用端口587 TLS加密,但我不能在端口587也給出了錯誤連接:Connection could not be established with host 31.149.66.10 [No route to host #113].

任何人都可以看到我在做什麼錯?

回答

1

如果拋出Swift_TransportException類型的異常,則意味着認證失敗。

早知道要不要認證失敗的異常將被拋出,呼籲建立運輸的start()方法

以下的清單將幫助你用這種錯誤的發現問題:

  • 檢查連接工作在其他郵件客戶端/平臺,使用相同的端口和憑證和加密
  • 檢查你的PHP安裝沒有TLS支持啓用。 您可以檢查是否「TLS」和/或「SSL」出現在你的PHP安裝使用PHP function stream_get_transports()

例如,您可以通過在php.ini中添加此添加它

extension=php_openssl.dll 
  • 確保沒有任何防火牆阻止連接,587可能被阻止
相關問題