This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

sHosting
sHosting

First issue

I want to edit email template body (created here: /backend/system/mailtemplates) before sending the email so I am using richeditor form widget with default value set via formExtendFields like this:

public function formExtendFields($form)
{

    $email_template = \System\Models\MailTemplate::findOrMakeTemplate('acme.plugin::mail.license_granted');

    $form->addFields([
        '_email_contents' => [
                'type' => 'richeditor',
                'size' => 'huge',
                'tab' => 'Add licenses',
                'default' => $email_template->content_html,
                'context' => 'create',
                'trigger' => [
                    'action' => 'show',
                    'field' => '_send_email_to_admin',
                    'condition' => 'checked'
                ]
            ]
    ], 'primary');
}

but the template property content_html is stripped from HTML tags... is this a bug or a feature, and am I doing something wrong?

Second issue

After submitting the _email_contents (see the first issue) I would like to use it to send the email (obviously). So I am using Mail::sendTo function like this:

[...]
$email_contents = post('License[_email_contents]');
$vars = ['{{ user }}' => $username, '{{ amount }}' => $quantity, '{{ school }}' => $school->name, '{{ link }}' => $link];
$email_contents = strtr($email_contents, $vars);
\Mail::sendTo($user->email, ['raw' => $email_contents]);

The email is sent but without a subject field. So my question is:

How to add a subject to sentTo function?

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.