Mautic Community Forums

Allow email created via API to be MJML

My idea is:

At the moment, when using the API to create a new email (/emails/new) you only have the option to send “customHtml” and “plainText” and there is no option to send the email content as MJML. As we changed our base template from HTML to MJML for the new editor, we now have to go back to the old HTML version for an email we want to send via the API.

Therefore, either allow MJML to be sent in the “customHtml” field and interpreted or add a new field for “customMJML” to the create email API endpoint.

I think these groups of people would benefit from this idea:

Anyone with MJML template(s).

Why I think they would benefit from this idea:

They could use the same template code for both templates and emails created via the API.

Hello!
Have you tested this feature with an MJML template as base template for the API call?
I think this is already working.
Joey

That isn’t what I mean, I meant sending an email to Mautic as “custom” MJML, like you can do with the customHtml field. I’ve tested this, but sending MJML in the customHtml field and that doesn’t work.

I’ve just looked at the docs again and maybe you are thinking about the /emails/ID/contact/CONTACT_ID/send endpoint, to send template emails to users and not emails/new to create a new email.

Hi,
No, I was thinking about /api/emails/new, which is a way to create a new email via API.
It does work perfectly with html, and I had the impression, I can do the same with MJML. I only have to use an mjml compatible base template in 'template' value I’m posting with the api call.

Man, I was wrong.

I also realized the lack of understanding I have for MJML templates. Only the “translated” html is stored in the emails.custom_html, the actual mjml code is in bundle_grapesjs.custom_mjml.

In order to make this happen, we would need to ‘inject’ the code right here via API and run the translator to create a html version of that mjml on the fly.

Joey

1 Like