Score:0

Webform HTML Email Fine on localhost with MailHog, Just Text on Server

kh flag

I Developed a webform on my localhost, testing the Email using Mailhog. Everything looks fine, nicely formatted html emails. When I moved it to my test server at A2Hosting, the emails all show as text. Using Drupal 9.2.7, Webform 6.1.2. I am not using any additional mail modules, just what comes with Drupal and Webform.

To move to my A2Hosting site, I just made a tarball, extracted, reloaded the database and got the site running. I do not know if Mailhog is just a poor choice for local email testing, if it is a problem at A2Hosting, or if I need some other module to make this work on the hosting site. It works fine on my local machine. The email header does seem very complex and I have included it below.

Note that EMClient says the email is formatted as html, but it show the html text.

Any idea what I need to do to get html email delivered from my hosting site?

Delivered-To: [email protected]
Received: by 2002:a67:e1de:0:0:0:0:0 with SMTP id p30csp745012vsl; Sun, 19 Dec
 2021 13:09:16 -0800 (PST)
X-Google-Smtp-Source: ABdhPJyMretpmTYP0W8WnE73MwAJmqWAs/sJzQf+2GGRxXLUNWB+ZTToY4dcwopzcjQX9LYHiRka
X-Received: by 2002:a17:903:2404:b0:148:db27:981a with SMTP id
 e4-20020a170903240400b00148db27981amr13552440plo.31.1639948156683; Sun, 19
 Dec 2021 13:09:16 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1639948156; cv=none; d=google.com;
 s=arc-20160816;
 b=nvnaX1XfnDvqdSZFi3oE8WHzEaA+58ovq9ABMbkwMZBXTGrEDONZktnFqbpIA29lsQ
 jnOes6zRpHNeqV+801eH9iJUx4OPG0GfiCFnY4EtKtMCqlTF40K1o3Pdt46rqOmX+oZT
 AvOpIhvE3RJcg6q4+6I32PCrha6ReIRyxaa77QUZ+6zuqEFxsgyksuYk8qZmBFXW4k2D
 dJ82XXO6AjeSE6+79dP8yWnKFUug7g066D9v6ZryB/mlLU94rfsf+g9mLVMiXlrXspi+
 vO98zo0mcylMN9hF6+KbM+BUWty4puvpbqfyMtSN4QQ0F/AUNrjWPyb472wfTz2vxIIs syWA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
 s=arc-20160816;
 h=date:from:message-id:mime-version:subject:to:dkim-signature;
 bh=CyxsiqnaEZFERiXIhFvUgPo5A/uykwhLvxMvB5XFUqY=;
 b=nZIUHh1Ax6I7+2VPsHtxEJMhZeEDx9EzHx19ry2b4ZORdpLLIPpazKuVNPq+XAp5U3
 0nQFEbl9pDbV4irgvGIqCNNHPr+JtjlZ7YX03hx4zNFpfDeKxGBl5ackl91K2zzbzg4X
 DmXGyQpHywwgFK/zNlpTvpyAbq5wXi5/us4ZyE5ytzY5vzlrku1KApoM8tvrhzhEtLmT
 /gGaWIt1cFZFT3K1zZUOeExKgNt2MyL0FEfNrM62JnYL1yl3jcA+XdeHD090uQx17GLV
 zPxqQXsywU9VRJz9eMffllNvP4LoTdtGUTiRKGNF5rzQGaqIj8KKgi597MnwkAPhwYmD Ckiw==
ARC-Authentication-Results: i=1; mx.google.com; dkim=pass
 [email protected] header.s=default header.b=VLU1Jaup;
 spf=pass (google.com: domain of [email protected] designates
 23.83.209.51 as permitted sender)
 [email protected]
Return-Path: <[email protected]>
Received: from dragonfly.birch.relay.mailchannels.net
 (dragonfly.birch.relay.mailchannels.net. [23.83.209.51]) by mx.google.com
 with ESMTPS id a22si8442075pff.212.2021.12.19.13.09.16 for
 <[email protected]> (version=TLS1_2
 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Dec 2021 13:09:16
 -0800 (PST)
Received-SPF: pass (google.com: domain of [email protected]
 designates 23.83.209.51 as permitted sender) client-ip=23.83.209.51;
Authentication-Results: mx.google.com; dkim=pass
 [email protected] header.s=default header.b=VLU1Jaup;
 spf=pass (google.com: domain of [email protected] designates
 23.83.209.51 as permitted sender)
 [email protected]
X-Sender-Id: a2hosting|x-authuser|[email protected]
Received: from relay.mailchannels.net (localhost [127.0.0.1]) by
 relay.mailchannels.net (Postfix) with ESMTP id E6FCE881065 for
 <[email protected]>; Sun, 19 Dec 2021 21:09:15 +0000 (UTC)
Received: from mi3-ts4.a2hosting.com (unknown [127.0.0.6]) (Authenticated
 sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id
 5FF62880BEC for <[email protected]>; Sun, 19 Dec 2021 21:09:15
 +0000 (UTC)
X-Sender-Id: a2hosting|x-authuser|[email protected]
Received: from mi3-ts4.a2hosting.com (mi3-ts4.a2hosting.com [70.32.23.71])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.97.65.154
 (trex/6.4.3); Sun, 19 Dec 2021 21:09:15 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: a2hosting|x-authuser|[email protected]
X-MailChannels-Auth-Id: a2hosting
X-Wipe-Ski: 4c75bb0d555c23f2_1639948155748_4128232018
X-MC-Loop-Signature: 1639948155748:545827072
X-MC-Ingress-Time: 1639948155748
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=hummingbirdhealingcenter.org; s=default; h=Date:From:Message-Id:
 MIME-Version:Subject:To:Sender:Reply-To:Cc:Content-Type:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:
 References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:
 List-Owner:List-Archive; bh=CyxsiqnaEZFERiXIhFvUgPo5A/uykwhLvxMvB5XFUqY=; b=V
 LU1Jauph2/wQjuiTs5ipSo6SMxn1AXD+B2JwT78QmstmyHDidi09umiRfXPcYJrI8+uYai0yMFhHk
 o3V4jTjgZ4vGAKHtiPYE+Pv0x6CYipWp5gwdrPNOuVCUb7q9MhvjhEgfs0zydC8GX8A6dBm6EyOH8
 jFeMrlzjQIKcBZ17lw6nMFze1CYswIjGvgK+98ilRTXAE9QoGvry9vPv0Wv8E2/LoVuXKesN/DTnI
 PQtjiHC/RcHFUGflr/z/YRpGaAJQsVLx/QUOBLoQf/iYN6Yc7l8p6qtaM7sZCaXo6yPCRDm0ahQtt
 OhfDuyn8/MmFEyK6BFXcbJTCUVTloWMFw==;
Received: from humming7 by mi3-ts4.a2hosting.com with local (Exim 4.94.2)
 (envelope-from <[email protected]>) id 1mz3Qg-000x6T-BR for
 [email protected]; Sun, 19 Dec 2021 16:09:14 -0500
To: [email protected]
Subject: Booking Form for Loremipsum
MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8; format=flowed
 Content-Transfer-Encoding: 8Bit X-Mailer: Drupal Sender:
 [email protected] From: HHC Booking Form
 <[email protected]> Reply-to: HHC Booking Form
 <[email protected]>
Message-Id: <[email protected]>
From: [email protected]
Date: Sun, 19 Dec 2021 16:09:14 -0500
X-AuthUser: [email protected]

<html>
<head>
Score:0
fr flag

Haven't you posted this somewhere else recently? I'm sure I answered this already. The problem is here:

MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8; format=flowed
 Content-Transfer-Encoding: 8Bit X-Mailer: Drupal Sender:
 [email protected] From: HHC Booking Form
 <[email protected]> Reply-to: HHC Booking Form
 <[email protected]>

That is all on one long line. That is wrong. There should be a \r\n before each header field name. With everything wrapped like that, the mail client receiving the mail doesn't see those headers and thus doesn't know it's an HTML formatted email. It should look like this:

MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Sender: [email protected]
From: HHC Booking Form <[email protected]>
Reply-to: HHC Booking Form <[email protected]>

The reason this is happening probably has something to do with your server email software or your mail module. The RFC mandates that \r\n be used as line terminators for mail headers, but historically this is something a lot of people get wrong - they tend to use the operating system's native line terminator instead. That is wrong.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.