2013-03-26 79 views
2

我試圖使用山魈標準Swiftmail SMTP連接,它位於:SwiftMail SMTP錯誤

http://help.mandrill.com/entries/21746308-Sending-via-SMTP-in-various-programming-languages

我得到一個:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.mandrillapp.com [Connection refused #111]' in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php:259 Stack trace: #0 /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/content/15/10121515/html/includes/classes/Swift/Transport/AbstractSmtpTransport.php(115): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/content/15/10121515/html/includes/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 /home/content/15/10121515/html/includes/mail.php(62): Swift_Mailer->send(Object(Swift_Message), Array) #4 {main} thrown in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php on line 259 

任何想法,爲什麼?

回答

4

這表明你沒有連接到山魈服務器,通常指的託管服務提供商阻止出站SMTP訪問,或者你正在使用的端口。您可以嘗試切換端口(Mandrill支持25,587和2525不加密或STARTTLS,端口465使用SSL),或聯繫託管服務提供商以查看他們是否可以打開您用於訪問Mandrill的端口。

0

有同樣的問題,我產生一個新的API密鑰,它工作得很好這一點。

0

今天我得到了同樣的問題。發現這個問題,但由於缺乏答案,我正在寫我如何解決它(我認爲你是在Linux下,因爲我)。

顯然的問題是,沒有安裝的郵件服務器。所以你必須找到你選擇的服務器並安裝它。我用postfix並按照以下方式安裝它:

sudo apt-get install postfix 

這解決了這個問題。

1

最有可能的,你的憑據是錯誤的。請重新檢查您的API密碼作爲密碼,並確保您使用正確的端口訪問smtp服務器。

此外,如果您在使用Symfony2的swiftmailer,確保你提供如下的默認設置:

在app/config.yml:

# Swiftmailer Configuration 
swiftmailer: 
    transport: "%mailer_transport%" 
    host:  "%mailer_host%" 
    username: "%mailer_user%" 
    password: "%mailer_password%" 
    port:  "%mailer_port%" 
    #spool:  { type: memory } 

此外,爲提供值在參數配置/ _dev.yml:

mailer_transport: smtp 
mailer_host: smtp.mandrillapp.com 
mailer_user: [USERNAME] 
mailer_password: [APIKEY] 
mailer_port: 587 
2

不要浪費你的時間和嘗試配置其他SMTP服務器(如Gmail,mandrillapp等)來處理您的外發電子郵件Ø n共享服務器。 GoDaddy,Hostgator等...已經阻止了這個選項。我發現離開「本地主機」作爲主機,擺脫用戶名和密碼就像一個魅力!看起來很簡單,但它是真的。

+0

確認 - 這個答案的作品。這對我來說就像一個魅力 - 網站託管在Go爸爸。 – user3158649 2016-01-26 05:19:54

+0

它工作!我們如何配置我們的GoDaddy共享主機使用mailtrap或mailgun發送郵件? – Jnanaranjan 2018-02-07 03:36:52

0

對於GoDaddy的共享服務器,它爲我工作。

'driver' => 'smtp', 
'host' => 'localhost', 
'port' => '587', 
'from' => array('address' => '[email protected]', 'name' =>'This is a Sign up mail'), 
'encryption' => 'tls', 
'username' => 'xxxxxxxx', 
'password' => 'xxxxxx', 
'sendmail' => '/usr/sbin/sendmail -bs', 
'pretend' => false,