Laravel Notification email per string

233 Views Asked by At

in my notifications i use the (MailMessage)->markdown('<file>') syntax and it works.

Not, i want to "inject" the markdown from outside, so i need something like this

(MailMessage)->markdown("<string">);

I think, you get the point.

When i now just give my markdown as a string to this function, it will not work and throws a

No hint path defined for [# Headline

Next line

error message.

So, how can i use string templates in my MailMessage markdown notifications?

1

There are 1 best solutions below

1
On BEST ANSWER

I'm not entirely sure why you'd want to put your markdown into a string as this is a bit counter-intuitive. The markdown method can only be used to specify the template path via dot notation - there is no current way to inject a markdown string.

However, what you could do is create a template that simply outputs whatever you pass to it (ie: the message/vars). For example:

(MailMessage)->markdown('my.markdown.template', ['data' => "my string here with markdown and whatnot"]);

Then, in your my.markdown.template, simply echo the data with nothing else: {{ $data }}