How to show image in email as content laravel notification

Viewed 377

I have created mail notification.. In which image is showing as attachment but I want to show image as content. How can I do this?

public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->greeting('Dear '.$this->fullname)
                    ->attach(public_path($this->image_path));
    }
1 Answers

Try to include image in blade, and then use blade as template for email.

Inside your notification change toMail:

return (new MailMessage)
    ->greeting('Dear '.$this->fullname)
    ->view('emails.test', [
        'image_path' => $this->image_path
    ]);

Then create new view emails/test.blade.php:

@component('mail::message')
{{--    some content--}}

    <img src="{{ asset($image_path) }}">

{{--    some content--}}
@endcomponent
Related