Lucas Tomic
Lucas Tomic

Reputation: 152

How to send an email with laravel?

I amtrying to send an email in a Laravel project, and it works in Localhost, but I have a lot of problems in a web server. This is what appears now: enter image description here

What does it means?

This is the ENV:

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.org
MAIL_PORT=587
MAIL_USERNAME=ltomicb@gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=merluzadepincho@gmail.com
MAIL_FROM_NAME="Merluza de Pincho"

Controller:

    public function mail(request $request){
    Mail::to('ltomicb@gmail.com')->send(new mdpMail($request));
    Session::flash('mensaje_enviado','Mensaje enviado correctamente.');
    return redirect('/contacto');
}

I have tried with mailgun but it was impossible to use it in a web server too.

Upvotes: 1

Views: 58

Answers (1)

Harout
Harout

Reputation: 174

you need to enable your 2 step verification from gmail account.

https://myaccount.google.com/security

then use the generated key from there to your ENV_PASSWORD instead your real password.

Upvotes: 2

Related Questions