Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel not sending mail to mailtrap inbox

I have tried using sendmail in laravel but it did not work . Check my post here Sending mails through Laravel is inconsistent

So , i tried using mailtrap's fake smtp server in laravel. It's not working here too. I am on Bitnami Mamp stack 7.1.15-0, Laravel 5.8 and testing it locally.

I followed this article to setup my code

https://blog.mailtrap.io/send-email-in-laravel/

I have created one free account in mailtrap. https://mailtrap.io/inboxes

and here is my configuration in .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=<myusername>
MAIL_PASSWORD=<mypassword>
[email protected]
MAIL_FROM_NAME=Example

My mail.php remains the same as default configuration.

My mailable's class (ReminderMail.php)'s build function

public function build()
{
    Log::info("Building the mailable class");


    return $this->from('[email protected]', 'Mailtrap')
        ->subject('Mailtrap Confirmation')
        ->markdown('emails.reminder')
        ->with([
            'name' => 'New Mailtrap User',
            'link' => 'https://mailtrap.io/inboxes'
        ]);


}

My client code

  echo "\n before sending mail";

    \Mail::to('[email protected]')->send(new \App\Mail\ReminderMail());

    echo "\n Mail sent";

My echos are printing properly.

My emails/reminder.blade.php file

 @component('mail::message')
Hello **{{$name}}**,  {{-- use double space for line break --}}
Thank you for choosing Mailtrap!

Click below to start working right now
@component('mail::button', ['url' => $link])
Go to your inbox
@endcomponent
Sincerely,  
Mailtrap team.
@endcomponent

But still i am not receiving mails in my mailtrap inbox.

Best Regards,

Saurav

like image 579
saurav Avatar asked Aug 18 '19 07:08

saurav


1 Answers

It might be an issue with cache. Run:

php artisan config:cache

This will clear and configure your cache again. Then try sending the email once again.

like image 170
zonecc Avatar answered Sep 20 '22 14:09

zonecc