Mail template & richeditor issue

Hello,

this is my mail template:


layout = "default"
subject = "{{campaign.subject}} "
==

<h1>{{ campaign.title }}</h1>
<h2>{{ campaign.sub_title }}</h2>
<h3>{{ campaign.summary|raw }}</h3>
<p>{{ campaign.content|raw }}</p>
{% for pic in campaign.picture %}
    <img src="{{ pic.getPath }}" alt="Picture" style="margin:50px 0"/>
{% endfor %}
<p>{{ campaign.more_content|raw }}</p>

{% for pic in campaign.more_pic %}
    <img src="{{ pic.getPath }}" alt="Additional Picture" style="margin:50px 0"/>
{% endfor %}

{% for file in campaign.files %}
    <a href="{{ file.getPath }}" download>{{ file.getFilename }}</a><br>
{% endfor %}

this is my function:

 public function onSendPreview($recordId = null)
    {
        log::info('send preview');
        $campaign = $recordId ? EmailCampaign::find($recordId) : null;
        log::info($campaign);

        if (!$campaign) {
            \Flash::error('La campagne n\'a pas été trouvée.');
            return;
        }

        $previewEmail = Input::get('preview_email'); 

        if (!filter_var($previewEmail, FILTER_VALIDATE_EMAIL)) {
            \Flash::error('Adresse email invalide.');
            return;
        }

        try {
            Mail::send('pixinside.mailusers::mail.campaign', ['campaign' => $campaign], function ($message) use ($previewEmail, $campaign) {
                $message->to($previewEmail);
                $message->subject($campaign->subject);
            });

            \Flash::success('Prévisualisation envoyée avec succÚs à ' . $previewEmail);
        } catch (\Exception $e) {
            Log::error('E-mail non envoyé', ['exception' => $e->getMessage()]);
            \Flash::error('Erreur lors de l\'envoi : ' . $e->getMessage());
        }

        return \Redirect::refresh();
    }

what is filtered with |raw doesn’t appear in the mail. If I remove the |raw filter, the text appears with the tags. I can’t figure out why, any ideas?

Of course, I add to post to the forum to find the answer! :grinning:

My |raw content was in between ‘p’ tags and so the html was wrong. correct code;


layout = "default"
subject = "{{campaign.subject}} "
==
{{ campaign.title }}
{{ campaign.sub_title }}
{{ campaign.summary }}

{{ campaign.content|striptags }}


==


!! wrap them in div tags

1 Like