Laravel 不向mailtrap 收件箱发送邮件

sau*_*rav 5 php laravel laravel-mail

我曾尝试在 laravel 中使用 sendmail 但它没有用。在此处查看我的帖子通过 Laravel 发送邮件不一致

所以,我尝试在 Laravel 中使用 mailtrap 的假 smtp 服务器。它在这里也不起作用。我在 Bitnami Mamp 堆栈 7.1.15-0、Laravel 5.8 上并在本地进行测试。

我按照这篇文章来设置我的代码

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

我在 mailtrap 中创建了一个免费帐户。 https://mailtrap.io/inboxes

这是我在 .env 文件中的配置

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=<myusername>
MAIL_PASSWORD=<mypassword>
MAIL_FROM_ADDRESS=from@example.com
MAIL_FROM_NAME=Example
Run Code Online (Sandbox Code Playgroud)

我的mail.php 与默认配置保持一致。

我的可邮寄类 (ReminderMail.php) 的构建功能

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


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


}
Run Code Online (Sandbox Code Playgroud)

我的客户代码

  echo "\n before sending mail";

    \Mail::to('newuser@example.com')->send(new \App\Mail\ReminderMail());

    echo "\n Mail sent";
Run Code Online (Sandbox Code Playgroud)

我的回声打印正常。

我的电子邮件/reminder.blade.php 文件

 @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
Run Code Online (Sandbox Code Playgroud)

但是我仍然没有在我的 mailtrap 收件箱中收到邮件。

此致,

索拉夫

小智 7

可能是cache. 跑:

php artisan config:cache
Run Code Online (Sandbox Code Playgroud)

这将再次清除并配置您的缓存。然后再次尝试发送电子邮件。