Below are my mail code and configuration. The issue which I'm facing is that mail() is not working, but I'm getting the output as mail sent (from code,when 'pretend' => false,) and not sent ('pretend' => true, and I also get "server.INFO: Pretending to mail message to:soandso@mail.com " in the log file ).What could be the issue? Same code is working for another site hosted with the same provider( GoDaddy)
$mail= Mail::send($view, $data, function ($message) use ($email, $subject, $data) {
if (isset($data['senderEmail'])) {
$message->from($data['senderEmail'], $data['senderFullname']);
}else{
$defult=\DB::table('settings')->select('value')->where('option','=','defaultMail')->first();
$message->from($defult->value, 'mailFrom');
}
if (isset($data['attachment'])) {
$message->attach($data['attachment']);
}
$message->to($email)->subject($subject);
});
if($mail){
dd("mail sent");
}else{
dd("not sent");
}
.env file
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=XXXXXXXX@gmail.com
MAIL_PASSWORD="XXXXXXXX"
MAIL_ENCRYPTION=tls
SENDERS_EMAIL=XXXXXXXX@gmail.com
SENDERS_NAME=afsal
config/mail.php
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,