My error is here:
Failed to authenticate on SMTP server with username "almamun00021@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. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials k24sm4734732pgf.59 - gsmtp ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials k24sm4734732pgf.59 - gsmtp ". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials k24sm4734732pgf.59 - gsmtp ".
.env file configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=almamun00021@gmail.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'almamun00021@gmail.com', 'name' => 'NewShop'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
<?php
controller:
namespace App\Http\Controllers;
use App\customer;
use Illuminate\Http\Request;
use Mail;
use Session;
class CheckoutUserController extends Controller
{
public function index()
{
return view('userAuth.login');
}
public function UserSignup(Request $request)
{
$customer = new customer();
$customer->username = $request-> username;
$customer->email = $request-> email;
$customer->phone = $request-> phone;
$customer->password = bcrypt($request-> password);
$customer->save();
$customerId = $customer->id;`
enter code here
Session::put('customerId',$customerId);
Session::put('Username',$customer->username);
$data = $customer->toArray();
Mail::send('mail.confirmation-mail',$data, function ($message) use ($data){
$message->to($data['email']);
$message->subject('Confirmation mail');
});
return "success";
}
}