You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mail::message component inside both views like @component('mail::message') at the top.
Now when we send the mail, the plain-text there has two issues:
The vendor/mail/text view namespace isn't used for plain-text view; instead the html view namespace is used.
View actually gets parsed by the markdown parser.
We don't want any of the above when we need to render a plain-text message for emails, it has MIME type of text/plain which any markup is useless and will be displayed to final users.
Screenshot of Mailhog "Plain text" tab showing the vendor/mail/html/layout view:
I did some debugging and I found that Mailable uses buildMarkdownText which it calls renderText only if textView is null
If there is actually a text view, we don't use it and we send the view alias back to the Mailer instead of using renderText and use the proper text view!
If I change this behaviur, and actually use textView if not empty like:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There is an issue when I try to use a markdown mailable that also is having a text view that will render as plain-text.
I'm using
mail::message
component inside both views like@component('mail::message')
at the top.Now when we send the mail, the plain-text there has two issues:
vendor/mail/text
view namespace isn't used for plain-text view; instead the html view namespace is used.We don't want any of the above when we need to render a plain-text message for emails, it has MIME type of
text/plain
which any markup is useless and will be displayed to final users.Screenshot of Mailhog "Plain text" tab showing the

vendor/mail/html/layout
view:I did some debugging and I found that
Mailable
usesbuildMarkdownText
which it callsrenderText
only iftextView
isnull
framework/src/Illuminate/Mail/Mailable.php
Lines 345 to 349 in 915d44e
If there is actually a text view, we don't use it and we send the view alias back to the
Mailer
instead of usingrenderText
and use the proper text view!If I change this behaviur, and actually use
textView
if not empty like:It will actually works and we'll get a clean plain-text message like this:

I consider this to be a bug and of course I can provide a PR if we conclude that this is the intended behaviour.
Beta Was this translation helpful? Give feedback.
All reactions