Support for Mailjet

Created on 16 April 2025, 11 days ago

Problem/Motivation

The Easy Email module constructs the email body as a render array using #theme => easy_email_body_html and the associated entity context. This is fine within the Drupal ecosystem but causes issues when using mail delivery services like Mailjet via contributed mail plugins (e.g., MailjetMail), which expect a string of rendered HTML, not a render array.

When sending a test email using Easy Email with Mailjet as the mail plugin, the email fails to send due to an incompatibility: Mailjet receives a render array instead of rendered HTML, resulting in PHP errors or empty emails.

This problem affects any external mail delivery plugin that expects a finalized string for the message body.

Steps to reproduce

Install and configure the Easy Email module.

Install and configure the Mailjet Mail module as the default mail system.

Create and configure an email template using Easy Email.

Attempt to send a test email using the Easy Email interface.

Observe that the message fails due to a type mismatch or content issues with body.

Proposed resolution

Ensure that the email body is rendered into an HTML string before it is passed to the mail plugin. This can be done in either of two ways:

Render the $message['body'] array using \Drupal::service('renderer')->renderRoot(...) within Easy Email before calling MailManager::mail().

Alternatively, allow Easy Email to pass a render array, but provide a documented hook or service point where site builders or contrib modules can inject body rendering logic.

Remaining tasks

User interface changes

None.

API changes

None immediately, but the way the email body is passed internally may be updated (i.e., render array to HTML string). This may affect downstream plugins relying on the body structure.

Data model changes

None.
Confirm where in the Easy Email sending flow the body is constructed and passed to the mail manager.

Add a rendering step before the final call to MailManager::mail(...).

Ensure that existing hooks and integrations are preserved.

Add test coverage for sending emails through render-array-sensitive mail plugins (like Mailjet).

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India sriharsha.uppuluri Hyderabad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024