I am using the Mail::send service to send an email from a contact form. The body of the email is HTML, provided with the richeditor. I have a template 'my.plugin::mail.default':
subject = "Overwritten"
==
<p>Hi {{ name }},</p>
{{message_body | raw}}
<p>This email was sent using formatting (HTML)</p>
and the code to send is like this:
$data=post();
$vars = [
'subject' => $data['subject'],
'message_body' =>$data['message'],
'name'=>'STB '
];
Mail::send('my.plugin::mail.default', $vars, function ($message) use ($vars) {
$message->to("reciever@email.com");
$message->subject($vars['subject']);
});
Email sent this way has the HTML message striped and only first tag (ex: <p>abc<p/>) is sent.
After many test, I figured out that when the HTML has the new-line character \n (as var $html below), Mail::send sends the message correctly. However, when the HTML hasn't the new-line character (as var $html_richeditor below), then it is cut.
$html = '<p>Aenean finibus erat eget maximus luctus. Phasellus vitae lectus dolor. Morbi convallis ex et turpis porttitor mattis morbi convallis ex et turpis porttitor mattis</p>
<p>Proin porta, nibh eget elementum aliquet, metus elit viverra nisi, vitae ullamcorper elit eros ut urna.</p>
<br/><br><p>Morbi convallis ex et turpis porttitor mattis.</p>';
$html_richeditor = "<p>Aenean finibus erat eget maximus luctus. Phasellus vitae lectus dolor. Morbi convallis ex et turpis porttitor mattis morbi convallis ex et turpis porttitor mattis</p><p>Proin porta, nibh eget elementum aliquet, metus elit viverra nisi, vitae ullamcorper elit eros ut urna.</p><p><br></p><p><br></p><p>Morbi convallis ex et turpis porttitor mattis.</p>";
Any idea how I can send the whole HTML from the richeditor? Should I config something in the richeditor or in the Mail?