Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FARDEEN's avatar

Unable to send email to gmail accounts

Hello, I am trying to integrate email into my Laravel application. I am not using mailtrap or google's SMTP. My domain provider has an email server. I am planning to use that email server. I have put all the environment settings but am still unable to send emails to my Gmail account. However, If I send an email to the same email account (from which the email is being sent, which is an email account of my domain) it works. Did anyone face this issue?

My env

MAIL_MAILER=smtp
MAIL_HOST=mail.domain.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=secrect
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

Route:


Route::get('mail', function () {
    $email = "[email protected]";
   
    $mail_data = ['verification_code' => 'aaa', 'name' => 'name'];
    
    // Mail::to('[email protected]')->send(new RegistrationEmail($data));
    // dd(env('MAIL_USERNAME'), env('MAIL_PASSWORD'), env('MAIL_FROM_ADDRESS'));

    Mail::send('mail.registration-email', $mail_data, function ($message) use($email) {
        $message->from(env('MAIL_USERNAME'), 'Test');
        $message->to($email)->subject('SUB');
    });
});

Using Laravel 7

0 likes
17 replies
FARDEEN's avatar

@Sinnbeck Thank you for your reply. I have sent them an email at their test address. It has reloaded 16 times so far as The boat progressbar finishes. Still no result

FARDEEN's avatar

@Sinnbeck It came up with a result page and it says

Number 1 reason for this page Your email client, plugin or extension said "sent", and it sure did. But your email got stopped just after, and never got sent. Why? Your SMTP or web host is probably blocking your emails. Quite common. Get in touch with them now to find out.

But if I send an email to my Gmail account using an email client for the domain (roundcube) the mail reaches my inbox just after few seconds.

Sinnbeck's avatar

@FARDEEN so contact your email host. They probably need to allow your mail to be used to send from your webserver

Sinnbeck's avatar

Did you try setting encryption? I assume it's starttls

MAIL_ENCRYPTION=tls
FARDEEN's avatar

@Sinnbeck Just tried. But still not working. I guess it was already tls because in the mail.php

'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],
		...
];
Snapey's avatar

typically these

[email protected]
MAIL_PASSWORD=secrect

must be valid credentials for a mailbox that you can access? are they? can you login to roundcube with these?

if so, the other settings need verifying with the provider or their docs

Also make sure you don't run artisan config:cache until you are in production and everything works

FARDEEN's avatar

@Snapey Yes, sir. I can log in. Even, if I send an email to my Gmail account (jamiul.bari98@gmail.com), I get a notification on my phone after a few seconds.

I don't apply config:cache in development but during debugging this issue, I have tried config:clear command after seeing a few StackOverflow posts

Snapey's avatar

@FARDEEN

if I send an email to my Gmail account (jamiul.bari98@gmail.com), I get a notification on my phone after a few seconds.

what does this mean? You send from roundcube and you gets to gmail? How would that be relevant to the problem?

FARDEEN's avatar

@Snapey Not directly relevant. Now, I do not have experience with email servers. What I want to say is, If I can send an email from "[email protected]" to "[email protected]" using RoundCube, then I think the mail server is working. But my Laravel application cannot send mail using the mail server. So, probably there is some mistake in my Laravel application.

Snapey's avatar

@FARDEEN Yes. For which you need the relevant details from the mail server provider and confirmation that they permit sending of email from other scripts.

For instance, how do you know that MAIL_HOST is correct, or MAIL_PORT or MAIL_ENCRYPTION ?

FARDEEN's avatar

@rudisang When I posted this, I was trying to send the mail via an email server (provided by the domain provider) that was running cPanel webmail. I could not use that server to send my emails (someone told me maybe it was related to some internal routing issues of cPanel webmail or something similar).

Then, what I did is, I searched for third-party email services. And I found sendinblue.com to be quite good (300 emails per day).

I tried it, and it still works great. If you follow this path, one issue you might face is, you may follow their documentation and other online tutorials using sendinblue where they use port 465. However, it did not work for me since port 465 has SSL-related stuff. So, port 2525 worked for me.

Please or to participate in this conversation.