Bug Report: Double HTML Wrapper When Using Elementor Forms + Email Templates
-
Following up on my previous thread, I was finally able to identify the real issue with my problem — which was not related to the other plugin called Elastic Email Sender as I thought but rather to Email Templates. For this reason, I would like to report an issue with the Email Templates plugin when it is used together with Elementor forms and external email gateways such as Elastic Email Sender, SMTP plugins, etc.
📌 Summary of the Issue
When Elementor sends HTML-formatted emails, the Email Templates plugin wraps the entire message inside a second full HTML layout.
The result is a duplicated HTML wrapper, for example:<html>
<body>
<html>
<body>
... email content ...
</body>
</html>
</body>
</html>This happens because Elementor already generates a complete HTML email, including:
<html>tag<body>tag- full layout and CSS
Then Email Templates applies its own template via:
$temp_message = $this->add_template( apply_filters( 'mailtpl_email_content', $args['message'] ) );This leads to invalid markup, rendering issues, and compatibility problems with external email services.
📌 How We Identified the Root Cause
After debugging:
- Elementor produces a full HTML email → correct
- Email Templates wraps the message again → causes duplication
- Elastic Email Sender simply transmits the received HTML → not the cause
- The test email from Elastic Email works correctly → confirms duplication happens before sending
- Disabling Email Templates fixes the issue immediately → confirms true source
So the issue is strictly in the plugin’s email wrapping logic.
📌 Proposed Patch (Solves the Problem for Elementor Users)
Inside
class-mailtpl-mailer.php, in thesend_email()method, the plugin should detect when a message already contains a complete HTML structure and skip wrapping.Here is the recommended patch:
public function send_email( $args ) {
do_action( 'mailtpl_send_email', $args, $this );
// Prevent double HTML wrapper for email builders like Elementor
$has_full_html = (
strpos($args['message'], '<html') !== false &&
strpos($args['message'], '<body') !== false
);
if ( $has_full_html ) {
// Elementor already outputs complete HTML – skip Email Templates wrapper
$user_email = isset($args['to']) ? $args['to'] : get_option('admin_email');
$args['message'] = $this->replace_placeholders(
$args['message'],
$user_email
);
return $args;
}
// Normal behavior for WP plain text emails
$temp_message = $this->add_template(
apply_filters( 'mailtpl_email_content', $args['message'] )
);
$user_email = isset($args['to']) ? $args['to'] : get_option( 'admin_email' );
$args['message'] = $this->replace_placeholders( $temp_message, $user_email );
return $args;
}✔ What this patch does:
- Prevents double wrapping for Elementor and other tools that generate full HTML
- Keeps Email Templates fully functional for WordPress system emails
- Maintains compatibility with SMTP plugins, Elastic Email Sender, WP Mail, etc.
- Ensures proper email rendering across clients
This preserves 100% of the plugin’s intended functionality, while fixing the duplication issue for modern page builders and form tools.
📌 Request
Would you consider integrating this logic into a future release?
It would greatly improve compatibility for Elementor users and prevent invalid email markup.I’d be happy to help test any version or assist further if needed.
Thank you very much for the great work on this plugin!
Best regards,
Emiliano
You must be logged in to reply to this topic.