10

I had ordinary Mailable that had some hardcoded content.

I've published mailable views, changed content to markdown and replaced ->view with ->markdown.

Now mail have nicely formated markdown.

However Laravel after compiling that markdown will pick HTML component definitions, for reasons I can not phantom. And that after it used Markdown version for message, so it's mixing both kinds in a single Mailable markdown view!

I've tried:

  • php artisan cache:clear
  • php artisan view:clear
  • adding markdown to html components - wont work, Laravel use them past markdown compilation step
  • changing ->markdown to ->markdown - yes it will give error about unexisting method

Using: PHP 7.0, Laravel 5.4.28

Q: Is there any Laravel global setting that would override ->markdown call? Any other ideas what may be wrong?

przemo_li
  • 3,932
  • 4
  • 35
  • 60
  • Did you by any chance come across any place in Laravel where those markdown views in `resources/views/vendor/mail/markdown/*` are actually used since you posted this question? I've been trying to locate such place, but it also seems to me it's just a 'dead code'. The only use case that comes to my mind would be using them as components in your markdown views, e.g. including them as: `@component('vendor.mail.markdown.panel`)`, but I have no idea why would you want to do it. – Amade Mar 09 '18 at 14:16
  • 1
    I found the answer: markdown views are used for the *plain text* version of emails. https://github.com/laravel/framework/issues/20791 – Amade Mar 09 '18 at 14:43

2 Answers2

1

Re reading the docs:

Markdown mailables support Blade templates. Blade support only ordinary html and blade syntax.

Individual components can use markdown compilers to parse some or all inputs. That's how @component('mail::table') works.

Update: Markdown versions are used to generate plain text mails. Where as blade templates are used to generate html versions. Again, markdown can be compiled explicitly in blade templates, but that's the extend of it's support.

przemo_li
  • 3,932
  • 4
  • 35
  • 60
  • I agree that one needs to be careful that in `->markdown('my-view')`, `my-view` is *not* raw markdown, it's a blade file in which specific components can be used, and it's *they* which will parse markdown that's slotted into them. – mwal Mar 24 '18 at 13:26
  • By 'markdown versions of components', do you mean the 'markdown' directory in vendor/mail/, after calling vendor:publish? I also find the purpose of the publishable vendor directory 'markdown' a mystery at the moment. – mwal Mar 24 '18 at 13:26
0

I think you need to follow laravel documentation here:https://laravel.com/docs/5.4/mail#markdown-mailables and also you could check laravel news article https://laravel-news.com/laravel-markdown-emails.

MD Iyasin Arafat
  • 763
  • 1
  • 12
  • 22