Skip to content
Advertisement

Laravel mail will not receive by gmail users

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}"

Advertisement

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

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement