Reputation: 63
i am now building one quite big sized enterprise grade web application on our production server.
while i was developing on local development server, sending mail was not a big concern, but in the live step it became a big pain in my butt.
i've searched like more than 3days and tried to use mandrill, postfix and sendmail driver options in the Laravel, still i could not get it happen.
so anyone, who experienced developing sending emails on Laravel with google apps account???
APP_DEBUG=true
APP_KEY=my app key
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mandrillapp.com
[email protected]
MAIL_PASSWORD=my api key
above is my .env file of the web application
and log shown below is the log, when the mail send fails
[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:
just incase i will provide some useful information.
above shown link does not work with google apps accounts
Upvotes: 0
Views: 2591
Reputation: 2716
This is an answer using gmails smtp server
In your 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' => '[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',
If you are using two step verification you need to get an app password. To do this go to your google account, sign in settings and add a new app. You will need to select other. Google will give you a password which you will need to use in this config file
Upvotes: 1