umanda's avatar

If you need to use gmail try this. I have tested this on my local. it is working for me.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your_gmail_address@gmail.com
MAIL_PASSWORD=your_gmail_address_password
MAIL_ENCRYPTION=tls

MAIL_PRETEND = false

Optional

MAIL_FROM_ADDRESS = from@email.com
MAIL_FROM_NAME = Sender's Name

Additionally you can use mailtrap ( https://mailtrap.io ) which is very handy for development.

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME= your_mailtrap_username  # This is auto generated one. you can find it once you create your mailtrap account 
MAIL_PASSWORD=your_mailtrap_password  #  Again t his also auto generated one. you can find it once you create your mailtrap account 
MAIL_ENCRYPTION=null
MAIL_PRETEND = false
MAIL_FROM_ADDRESS = from@email.com
MAIL_FROM_NAME = Sender's Name

Note : You may need to change mail.php ( config\mail.php ) to use MAIL_FROM_ADDRESS , MAIL_FROM_NAME , MAIL_PRETEND keys

mine

return [

    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    'port' => env('MAIL_PORT', 587),
 'from' => ['address' => env('MAIL_FROM_ADDRESS'), 'name' => env('MAIL_FROM_NAME')],
 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
 'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => env('MAIL_PRETEND', false),
];

Hope this will help you :)

Happy Coding.

manoj10029's avatar

Change your main dirvers with key word 'mail' or 'sendmail'

MAIL_DRIVER=sendmail MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=manoj10029@gmail.com MAIL_PASSWORD=********** MAIL_ENCRYPTION=ssl MAIL_FROM=manoj.prismic@gmail.com MAIL_NAME=Manoj

It may help you

StageCoachDriver's avatar

Configuring WP to send email is a snap. Configuring Laravel to send email is yet another mountain to climb - and I'm not sure this is the mountain I want to die on.

Jelmer's avatar

Late to the thread but this is what makes gmail run on a Digital Ocean vps: Digital Ocean blocks SMTP by default on IPv6 so you need to allow that by editing

/etc/gai.conf

and uncommenting:

#precedence ::ffff:0:0/96 100

reboot

// still mailgun or equivalent is preferred over any smtp connection

1 like
shu3aybbadran's avatar

@rahulyadav did you found and answer after one year :) i have same problem , work fine on localhost but not in production ?

JunaidMasood's avatar

1: Either you must allow less secure apps or use app password by enabling 2 step verification on your gmail acc.

2: Disable any antivirus on your machine(this is something no one will tell u but is necessary in many cases).

3: Don't forget to clear your cache (sometimes it don't take updated content from .env file)

4: You don't need to change anything in Mailer inside config directory(not recommended), you should use env variables

Previous

Please or to participate in this conversation.