Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Allow to set plain HTML in mails #22809

Merged
merged 4 commits into from
Jan 18, 2018
Merged

[5.6] Allow to set plain HTML in mails #22809

merged 4 commits into from
Jan 18, 2018

Conversation

abellion
Copy link
Contributor

We use MJML as a template engine for our mails. It returns us plain HTML, so having this PR merged would make easier setting plain HTML to mails (we use a blade "wrapper" today as a workaround).

@taylorotwell
Copy link
Member

Can you explain more what you mean by "plain" HTML? Doesn't the mailer already allow you to send views? Or you mean there is no view at all?

@abellion
Copy link
Contributor Author

Yeah there is no view at all.

@taylorotwell
Copy link
Member

taylorotwell commented Jan 17, 2018

I'm wondering if it makes sense to do this. AFAIK it's good practice to always include a text part:

if (isset($this->html)) {
    return array_filter([
        'html' => new HtmlString($this->html),
        'text' => isset($this->textView) ? $this->textView : null,
    ]);
}

@abellion
Copy link
Contributor Author

abellion commented Jan 17, 2018

Yes you're right, I've updated the html() method of the Mailable class.

Should I also update the one from the Mailer class ?
The signature could looks like this :

public function html($html, $callback, $plain = null);

What do you think ? The raw and send methods don't give this possibility, so maybe it's unnecessary.

@taylorotwell
Copy link
Member

I don't think it's necessary on Mailer since I could always just call Mail::send(['html' => foo, 'text' => bar]) already. So it's already possible there.

@abellion
Copy link
Contributor Author

abellion commented Jan 17, 2018

Makes sense.

@taylorotwell taylorotwell merged commit 055f50c into laravel:5.6 Jan 18, 2018
@abellion abellion deleted the 5.6-html-mail branch January 18, 2018 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants