Laravel mail will not receive by gmail users

1.9k views Asked by At

When I send email by laravel non-gmail accounts will receive emails but Gmail accounts will not, does anyone here faced such problem before? any idea what causes that?

As my emails are receiving with half of the users I don't think the issue is my code but just in case i share it here as well.

Observe

class SellerObserve
{
    public function created(Seller $seller)
    {
        Mail::to($seller->email)->send(new SellersWelcome($seller));
    }
}

mail

class SellersWelcome extends Mailable
{
    use Queueable, SerializesModels;
    public $seller;

    public function __construct(Seller $seller)
    {
        $this->seller = $seller;
    }

    public function build()
    {
        return $this->subject('Welcome')->markdown('emails.sellers.welcome');
    }
}

env

MAIL_MAILER=sendmail
MAIL_HOST=MY_SERVER_IP
MAIL_PORT=587
MAIL_USERNAME=MY_EMAIL_ADDRESS
MAIL_PASSWORD=MY_EMAIL_PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=MY_EMAIL_ADDRESS
MAIL_FROM_NAME="${APP_NAME}"
2

There are 2 answers

1
mafortis On BEST ANSWER

I've changed my mail settings to GMAIL (my sender will be gmail instead of my hosting) and then I've turned on less security from account settings, now it sends emails to all providers including gmail users.

env

MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=MY_EMAIL_ADDRESS
MAIL_PASSWORD=MY_EMAIL_PASSWORD
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=MY_EMAIL_ADDRESS
MAIL_FROM_NAME="${APP_NAME}"

one

1
Ajish Stephen On

To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.

Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date.

For more information, continue to read