octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.

Home Page:https://octobercms.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when sending e-mail

Dahfrenk opened this issue · comments

After the OctoberCMS 3.6 update and updating my plugins registerMail functions there is now a situation that I find kind of odd.
I have this;

    public function registerMailTemplates(): array
    {
        return [
            'author.plugin:alert' => 'author.plugin::mail.alert',
        ];
    }

Within this email template is a basic layout;

subject = "An issue has been detected!"
layout = "artisan"
description = "Mail that will be sent if an error occurs."
==
<p>{{ body|raw }}</p>

{% if buttonText and buttonLink %}
    {% partial 'button' url=buttonLink body %}
        {{ buttonText }}
    {% endpartial %}
{% endif %}

The odd situation comes in when this email is attempted to be send using;

            Mail::send('author.plugin::mail.alert', $vars, function ($message) use ($subject) {
                $message->to(Settings::get('receiver_mail'), Settings::get('receiver_name'));
                $message->subject($subject);
            });

The following message comes up:

Unexpected "partial" tag (expecting closing tag for the "if" tag defined near line 8) in ".../plugins/author/plugin/views/mail/alert.htm" at line 9.

When I go into the CMS and I delete the whole if statement and everything in it, the behavior is the same. Only if I go into the file and delete it there, does the mail send, but without the layout that I assigned to the template.

If however I go into the CMS and send the email, it works just fine.
I have already tried deleting the email template and it is being automatically created back (Which is good). But even after that, the same error persists. The error itself doesn't make much sense to me and I feel the issue might be rooted somewhere else.

commented

Hey,

It looks like your source mail view might have a Twig syntax error in it.

Try Mail::send('author.plugin:alert', ...);

I will mark this as resolved as using your reference worked but I still find it odd that the source mail threw an error while the content was exactly the same