K
K
kitcart2019-08-01 22:49:40
gmail
kitcart, 2019-08-01 22:49:40

How to solve the problem of sending mail using gmail in laravel?

Greetings!
I wanted to send mail, but an error occurs.

Failed to authenticate on SMTP server with username "*******@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted.

Login and password are 100% correct
Copying them from the config, pasting them into the Google authorization, everything is fine.
In .env config
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
MAIL_USERNAME=*****@gmail.com
MAIL_PASSWORD=************

an object
class FeedbackShipping extends Mailable
{
    use Queueable, SerializesModels;

    public $feedback;

    public function __construct(Feedback $feedback)
    {
        $this->feedback = $feedback;
    }

    public function build()
    {
        return $this->from('............')
            ->to('............')
            ->view('emails.feedback');
    }
}

Well, the call itself in the controller
public function send(Request $request)
    {
        $data = new Feedback(
            $request->get('name'),
            $request->get('phone')
        );

        Mail::send(new FeedbackShipping($data));
        
        return response()->json(['send' => 'ok']);
    }

Where to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergeyj, 2019-08-01
@kitcart

Perhaps your .env does not cling
For a test, try in the file bootstrap/app.phpbefore $app->singleton
adding the .env load

$app->loadEnvironmentFrom('/полный_путь_до_файла/.env');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question