我现在正在我们的生产服务器上构建一个相当大的企业级Web应用程序。
当我在本地开发服务器上开发时,发送邮件并不是一个大问题,但在实际步骤中,我的屁股变得非常痛苦。
我搜索的次数超过了3天,并试图在Laravel中使用mandrill,postfix和sendmail驱动程序选项,但我仍然无法实现。
所以任何人都经历过使用谷歌应用程序帐户在Laravel上发送电子邮件???
APP_DEBUG=true
APP_KEY=my app key
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mandrillapp.com
MAIL_USERNAME=admin@themandarin.co.kr
MAIL_PASSWORD=my api key
以上是我的Web应用程序的.env文件
当邮件发送失败时,和日志显示为日志
[2015-07-02 17:56:16] production.ERROR:异常'Swift_TransportException',消息'预期响应代码250但得到代码“535”,消息“535-5.7.8用户名和密码不被接受在^ M了解更多信息 535 5.7.8 https://support.google.com/mail/answer/14257 gs7sm4872423pbc.6 - gsmtp ^ M “在/home/thecorp-admin/Services/TheMandarin/Trinity/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383 堆栈跟踪:
只是因为我会提供一些有用的信息。
以上显示的链接不适用于Google Apps帐户
答案 0 :(得分:1)
这是使用gmails smtp server
的答案在App \ Config \ 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' => 'sender@email.co.uk', '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' => 'yourname@email.com',
/*
|--------------------------------------------------------------------------
| 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',
如果您使用两步验证,则需要获取应用密码。要执行此操作,请转到您的Google帐户,登录设置并添加新应用。您需要选择其他。 Google会为您提供一个密码,您需要在此配置文件中使用该密码