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
MAIL_ENCRYPTION=null
added to your environment file. It is part of the default mailtrap config. – Comictelnet smtp.mailtrap.io 2525
in a console to see whether the port is accessible at all. – Comic