0

Hi there I want to send an email using laravel. In localhost every thing is fine what in heroku its gives Failed to authenticate on SMTP server with username "mail@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534"

I have added .env variables in settings as well

here is code

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mail@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=mail@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

controller

 Mail::send('email', array(
                'name' => $request->name,
                'email' => $request->email,
                'phone' => $request->phone_number,
                'gender' => $request->gender,
                'institute' => $request->institute
            ), function($message) use ($request){
                $message->from($request->email);
                $message->to('mail@gmail.com')->subject($request->get('Apply Form'));
            });
kamran
  • 1

1 Answers1

0

Could you please try to use mail port 465 and encryption type as ssl in your SMTP settings?

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=mail@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=mail@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
kdrmlhcn
  • 96
  • 4
  • yes i have tried but still getting error 'using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534"' – kamran Oct 23 '21 at 10:02
  • @kamran You can follow these instructions https://stackoverflow.com/a/66011897/7811589 and you can try to use this 'php artisan config:clear' command. – kdrmlhcn Oct 23 '21 at 10:05
  • i try everything but not working – kamran Oct 23 '21 at 10:23
  • Did you try the 2 factor authentication and then creating a new app password. I had this exact problem a couple of weeks ago and that is the only thing which worked for me out of all the stack overflows answers there are. – rlong405 Oct 23 '21 at 11:46
  • It’s the bit in the P.S. of the link which @kdrmlhcn shared – rlong405 Oct 23 '21 at 11:47
  • what is the solution i have the same problem – entesar Dec 12 '21 at 14:45