2015-06-19 98 views
0

我正在使用Symfony,我試圖用swiftmailer發送郵件。我已經建立了與谷歌的應用程序的帳戶([email protected]),當我試圖給我顯示了以下錯誤:SwiftMailer不使用Google App帳戶發送郵件

Failed to authenticate on SMTP server with username "[email protected]" using 2 possible authenticators

我與我的個人Gmail帳戶嘗試過了,用正確發送消息相同的設置。只需更改用戶名和密碼。

# Swiftmailer Configuration 
swiftmailer: 
    transport: smtp 
    host:  smtp.gmail.com 
    username: [email protected] #[email protected] 
    password: google_app_password  #gmail_password 
    auth_mode: login 
    port:  587 
    encryption: tls 

我一直在尋找互聯網和我發現從谷歌,在那裏我可以改變存取安全性較低的應用程序此頁面。 https://www.google.com/settings/security/lesssecureapps

在我的Gmail帳戶中,此選項處於活動狀態,但如果我打開電子郵件時顯示同樣的錯誤。 我一直在嘗試在谷歌應用程序帳戶中更改此設置,但它告訴我,此選項不適用於谷歌應用程序。

任何想法從谷歌應用程序發送此帳戶的電子郵件?我必須設置別的東西?

編輯 看來Gmail的喜歡的OAuth,Swiftmailer支持此認證的機甲,但它不是真正的記錄。

https://developers.google.com/gmail/xoauth2_protocol https://github.com/swiftmailer/swiftmailer/blob/5.x/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php

任何想法,我如何使用它在Symfony的?

+0

鏈接的選項是消費者帳戶只我相信。我建議使用Google的SMTP中繼服務,詳細信息請參閱https://support.google.com/a/answer/2956491,以瞭解如何使用Apps設置此類功能。 – miketreacy

+0

可能要檢查這個http://stackoverflow.com/questions/26018224/swiftmailer-not-sending-emails-in-symfony-2-5/26020753#26020753 – Baig

回答

0

您是否試過按照食譜中提到的將傳輸參數設置爲gmail? http://symfony.com/doc/current/cookbook/email/gmail.html

# Swiftmailer Configuration 
swiftmailer: 
    transport: gmail 
    username: your_gmail_username 
    password: your_gmail_password 
+0

是的,我試過了,但它是相同的配置我用在我的例子中。 –