2015-07-02 21 views
0

我現在正在我們的生產服務器上構建一個相當大的企業級Web應用程序。發送電子郵件在Laravel 5谷歌應用程序帳戶不起作用

雖然我在本地開發服務器上進行開發,但發送郵件並不是一個大問題,但是在現場階段,它成了我屁股上的一大痛苦。

我已經搜索了超過3天,並試圖在Laravel中使用mandrill,postfix和sendmail驅動程序選項,但我仍然無法實現它。

所以任何人,誰開發發送電子郵件Laravel與谷歌應用程序帳戶?上述

APP_DEBUG=true 
APP_KEY=my app key 

MAIL_DRIVER=smtp 
MAIL_HOST=smtp.mandrillapp.com 
[email protected] 
MAIL_PASSWORD=my api key 

是Web應用程序

及以下日誌中顯示的我.ENV文件是日誌,當郵件發送失敗

[2015-07-02 17:56:16] production.ERROR: exception 'Swift_TransportException' with message 'Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at^M 535 5.7.8 https://support.google.com/mail/answer/14257 gs7sm4872423pbc.6 - gsmtp^M "' in /home/thecorp-admin/Services/TheMandarin/Trinity/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383 Stack trace:

只是櫃面我會提供一些有用的信息。

上面顯示的鏈接不與谷歌應用程序的工作佔

+0

嗨,我一直在使用Laravel發送電子郵件使用商業Gmail帳戶,並沒有太多的問題。您嘗試使用的帳戶是否有兩步驗證? –

回答

0

這是使用Gmail的SMTP服務器

在您的應用程序\配置\ mail.php

/* 
    |-------------------------------------------------------------------------- 
    | Mail Driver 
    |-------------------------------------------------------------------------- 
    | 
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the 
    | sending of e-mail. You may specify which one you're using throughout 
    | your application here. By default, Laravel is setup for SMTP mail. 
    | 
    | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log" 
    | 
    */ 

    'driver' => 'smtp', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Host Address 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may provide the host address of the SMTP server used by your 
    | applications. A default option is provided that is compatible with 
    | the Mailgun mail service which will provide reliable deliveries. 
    | 
    */ 

    'host' => 'smtp.gmail.com', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Host Port 
    |-------------------------------------------------------------------------- 
    | 
    | This is the SMTP port used by your application to deliver e-mails to 
    | users of the application. Like the host we have set this value to 
    | stay compatible with the Mailgun e-mail application by default. 
    | 
    */ 

    'port' => 587, 

    /* 
    |-------------------------------------------------------------------------- 
    | Global "From" Address 
    |-------------------------------------------------------------------------- 
    | 
    | You may wish for all e-mails sent by your application to be sent from 
    | the same address. Here, you may specify a name and address that is 
    | used globally for all e-mails that are sent by your application. 
    | 
    */ 

    'from' => ['address' => '[email protected]', 'name' => 'Ted notification'], 

    /* 
    |-------------------------------------------------------------------------- 
    | E-Mail Encryption Protocol 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may specify the encryption protocol that should be used when 
    | the application send e-mail messages. A sensible default using the 
    | transport layer security protocol should provide great security. 
    | 
    */ 

    'encryption' => 'tls', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Server Username 
    |-------------------------------------------------------------------------- 
    | 
    | If your SMTP server requires a username for authentication, you should 
    | set it here. This will get used to authenticate with your server on 
    | connection. You may also set the "password" value below this one. 
    | 
    */ 

    'username' => '[email protected]', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Server Password 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may set the password required by your SMTP server to send out 
    | messages from your application. This will be given to the server on 
    | connection so that the application will be able to send messages. 
    | 
    */ 

    'password' => 'myPassword', 

如果您使用的是答案您需要兩步驗證才能獲取應用密碼。要做到這一點去你的谷歌帳戶,登錄設置並添加一個新的應用程序。您將需要選擇其他。 谷歌會給你一個密碼,你需要在這個配置文件中使用

+0

這就是我所做的。 – user2809760

+0

您收到了哪些錯誤 –

+0

我在下面出現錯誤: 預期的響應代碼250但代碼爲「530」,並帶有消息「530-5.5.1需要驗證,請參閱 530 5.5.1 https:// support .google.com/mail /?p = WantAuthError e190sm2996547pfa.41 - gsmtp 「 –

相關問題