2013-07-31 126 views
4

在symfony2.3中,我使用了swiftmailer。swiftmailer使用gmail與自定義域發送電子郵件

我有一個谷歌Apps地址一樣[email protected]

當使用我的正常的Gmail地址[email protected]

mailer_transport: smtp 
mailer_encryption: ssl 
auth_mode:   login 
mailer_host:  smtp.gmail.com 
mailer_user:  myname 
mailer_password: pymass 

配置的偉大工程,它發送的郵件我Gmail地址,但使用[email protected]作爲mailer_user使用正確的密碼不起作用。

任何想法?

回答

7

從(我認爲是)Google Apps帳戶發送的配置不同於Gmail帳戶。你swiftmailer參數應該是這個樣子:

mailer_transport: smtp 
mailer_host:  smtp.gmail.com 
mailer_user:  [email protected] 
mailer_password: pymass 
auth_mode:   login 
port:    587 
encryption:  tls 

確保包括完整的電子郵件地址以及端口和加密協議。

幾個月前,我從this article推導出解決方案。

此外,小記:其encryption而不是mailer_encyption。您可以閱讀關於Symfony here的swiftmailer參數的更多信息。

0

當您在您的控制器中的信息或任何地方,它的存在,你把發件人(setFrom法)

// Create a message 
$message = Swift_Message::newInstance('Wonderful Subject') 
    ->setFrom(array('[email protected]' => 'John Doe')) 
    ->setTo(array('[email protected]', '[email protected]' => 'A name')) 
    ->setBody('Here is the message itself') 
; 

在配置文件中的mailer_user僅用於連接到Gmail的SMTP服務器。

+0

看看這個文檔: http://swiftmailer.org/docs/sending.html –

相關問題