Laravel 电子邮件中的图片

Laravel image in email

我正在尝试将无法显示的图片附加到电子邮件中

此代码通知

return (new MailMessage)
        ->from(config('mail.username'))
        ->subject('Reset Password')
        ->greeting('<img src="http://test.test/img/header/mail_head_en.jpg">')
        ->line('You are receiving this email because we received a password reset request for your account.')
        ->line('Your E-mail address ' . ' : ' . $notifiable->email)
        ->action('Reset Password', route('vendor.password.reset', $this->token . '?email=' . urlencode($notifiable->email)))
        ->line('If you did not request a password reset, no further action is required.');

但是,不显示图像到电子邮件

将邮件视图文件的 greeting 部分从 {{ $greeting }} 更改为 {!! $greeting !!}

在您的终端或 cmd 运行 此命令中:

php artisan vendor:publish --tag=laravel-notifications

现在转到第 4 行 resources/views/vendor/notifications/email.blade.php

改变

{{ $greeting }}

{!! $greeting !!}