<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Email message body not formatted correctly w/PHP 8</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Email-message-body-not-formatted-correctly-w-PHP-8-82544</link>
        <description></description>
        <pubDate>Mon, 20 Jul 2026 02:25:53 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Email-message-body-not-formatted-correctly-w-PHP-8-82544" rel="self" type="application/rss+xml" />

                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246122#post2246122</link>
          <description><![CDATA[<p>Daniel,</p>
<p>The modified <span>MailTransport.php solved the mail formatting issue for me. I've tested two different CMSB installs on two different servers, both with PHP 8.1.</span></p>
<p>Thank you so much!<br />~ Deborah</p>
]]></description>
          <pubDate>Tue, 30 Aug 2022 04:26:17 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246122#post2246122</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246121#post2246121</link>
          <description><![CDATA[<p>Hi all,</p>
<p>We were finally able to resolve this issue. It can be fixed by commenting out these lines (165-168) in /cmsb/3rdParty/SwiftMailer5/classes/Swift/Transport/MailTransport.php:</p>
<blockquote class="gmail_quote">$headers = str_replace("\r\n", PHP_EOL, $headers);<br />$subject = str_replace("\r\n", PHP_EOL, $subject);<br />$body = str_replace("\r\n", PHP_EOL, $body);<br />$to = str_replace("\r\n", PHP_EOL, $to);</blockquote>
<p><br />Note that this is a system-specific fix, i.e. only make this fix if your site is exhibiting the issue. It can happen on some Linux servers running PHP 8+, but not all. It is not backwards-compatible with PHP 7, so it won't be added to the official CMSB release. We will instead continue looking at a long-term fix that can be backwards compatible.</p>
<p>Cheers,</p>]]></description>
          <pubDate>Mon, 29 Aug 2022 12:35:53 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246121#post2246121</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246014#post2246014</link>
          <description><![CDATA[<p>Dave,</p>
<p>Your idea seems a good explanation for what I'm seeing with the random message line breaks.</p>
<p>I tried commenting out the else block, but still see the same. I'll submit a support request, as you suggested.</p>
<p>Thanks very much for looking at this.</p>
<p>~ Deborah</p>]]></description>
          <pubDate>Thu, 16 Jun 2022 14:43:01 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246014#post2246014</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246013#post2246013</link>
          <description><![CDATA[<p>Hi Deborah, </p>
<p>We had a look into this and it appears to be a known issue with PHP 8:</p>
<ul><li><a href="https://github.com/php/php-src/issues/8086" rel="nofollow">https://github.com/php/php-src/issues/8086</a></li>
<li><a href="https://www.drupal.org/project/webform/issues/3239517" rel="nofollow">https://www.drupal.org/project/webform/issues/3239517</a></li>
</ul><p>They changed how the internal PHP mail() function works so that it requires a multicharacter line ending (\r\n instead of \r\n or \n).  We can try changing it, but it may cause it not to work on other servers.  The PHP docs reference that here: <a href="https://www.php.net/manual/en/function.mail.php" rel="nofollow">https://www.php.net/manual/en/function.mail.php</a></p>
<blockquote>
<p>Note: If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.</p>
</blockquote>
<p>Sometimes what we do in these cases is add code that detects the PHP version to work around version-specific issues.  Often they revert it back a few versions later if it breaks too many servers.</p>
<p>We'll need to investigate further to find a universally workable solution, but try this: </p>
<ul><li>Open cmsb/3rdParty/SwiftMailer5/classes/Swift/Transport/SendmailTransport.php</li>
<li>Search for "\n"</li>
<li>Comment out the line in the else block</li>
</ul><pre class="language-php"><code>if (false === strpos($command, ' -i') &amp;&amp; false === strpos($command, ' -oi')) {
  $buffer-&gt;setWriteTranslations(array("\r\n" =&gt; "\n", "\n." =&gt; "\n.."));
} else {
  # Comment this line # $buffer-&gt;setWriteTranslations(array("\r\n" =&gt; "\n"));
}</code></pre>
<p><br />Let me know if that makes a difference.  If not could you fill out a second level support request here: <a href="https://www.interactivetools.com/support/request/" rel="nofollow">https://www.interactivetools.com/support/request/</a></p>
<p>Hope that helps!</p>]]></description>
          <pubDate>Thu, 16 Jun 2022 10:32:41 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246013#post2246013</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246010#post2246010</link>
          <description><![CDATA[<p>Daniel, thanks for the ideas for narrowing things down. No luck yet, but here's where I'm at:</p>
<ul><li>I tried, but am not able to run pre-v3.55 installs when switched to PHP 8, because errors prevent the admin login screen from displaying.<br />ERROR: "Too few arguments to function _errorlog_catchRuntimeErrors()...." (removed the rest of this message)</li>
<li><span>I am using PHP's built-in mail() function. I've not been able to get SMTP connections to connect for many versions and am not able to with 3.56 either.</span></li>
<li>Today I tried a fresh install of 3.56 on a different server (updated to PHP 8.0.20) and got the same email template errors, with the HTML displaying in the body of the message.</li>
<li>In addition to sending password reset emails to Microsoft Outlook on my PC, I also sent to Gmail and Outlook.com and see the same email issue.</li>
</ul><p><span>I've now tested on at least 4-5 different installs over two different servers and all emails are coming through similarly.<br /></span><span>There are equal signs "=" randomly inserted into the messages, which could be breaking the HTML<br />PARTIAL EXAMPLE:</span></p>
<pre class="language-markup"><code>&lt;p&gt;Hi you@yourdomain.com,&lt;/p&gt;
&lt;p&gt;You request=
ed a password reset for CMS Builder.&lt;/p&gt;
&lt;p&gt;To reset your password click =
this link:
...</code></pre>
<p><span>I've exhausted all of my testing ideas here. If you have other suggestions of things for me to try, I'd be happy to do so.</span></p>
<p><span>Thanks for your help on this!<br />~ Deborah</span></p>]]></description>
          <pubDate>Wed, 15 Jun 2022 16:46:46 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246010#post2246010</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246005#post2246005</link>
          <description><![CDATA[<p>Thanks for the info Deborah! Keep me posted on what you find with other email clients.</p>
<p>A few other questions that might help narrow things down:</p>
<ul><li>If possible, are you able to test using a Pre-v3.55 CMSB install running PHP 8? This is outside compatibility and will likely generate errors so I understand if you're not able to do this, but it would help to know if the combination of CMSB and PHP versions has any effect, of if it's purely an issue with PHP 8.</li>
<li>For the site(s) having the issue, on the Email Settings configuration page, is "How to send mail" set to use PHP's built-in mail() function, or is it set up to send through an SMTP server? </li>
</ul><p>Thanks!</p>]]></description>
          <pubDate>Tue, 14 Jun 2022 15:17:10 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246005#post2246005</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2246001#post2246001</link>
          <description><![CDATA[<p>Daniel, I appreciate your reply. If you can't replicate the issue, then there is hope!</p>
<p>I'm viewing email received in Microsoft Outlook 2016. Emails generated by CMSB installs prior to <span>3.55 or 3.56 (with older PHP versions) still look good.</span></p>
<p>I'll try sending to other email clients and let you know what I find.</p>
<p>Thanks again!<br />~ Deborah</p>]]></description>
          <pubDate>Tue, 14 Jun 2022 13:47:32 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2246001#post2246001</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245999#post2245999</link>
          <description><![CDATA[<p>Hi Deborah,</p>
<p>This is an odd issue, but not the first we've seen it. Could you let me know what email client you're using, and possibly try to send out to some different email addresses using different clients (e.g. gmail, outlook, etc.)? I wasn't able to find any specific discrepancies between how PHP 7.4 and 8.1 send out emails, so it may help to check for any client differences.</p>
<p>Thanks,</p>]]></description>
          <pubDate>Tue, 14 Jun 2022 12:45:51 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245999#post2245999</guid>
        </item>
                <item>
          <title>Email message body not formatted correctly w/PHP 8</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245972#post2245972</link>
          <description><![CDATA[<p>I am experiencing issues with CMSB 3.55 and 3.56 emails.</p>
<p>It's happening with various email templates, the Auto Backup plugin email, and the password reset email. The body of the messages contain raw HTML and the Auto Backup does not send a zip attachment of the backup. I am using PHP's built-in mail() function in the settings.</p>
<p>The following two examples happen with CMSB v3.55 or v3.56 with PHP <span>8.0.18 </span>or 8.1.5 (same results with any combo). Setting back to PHP 7.4 works fine.</p>
<p>#1 - Example from /admin.php?menu=forgotPassword</p>
<pre class="language-markup"><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="">http://www.=</a>
<a href="w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"&gt;
&lt;html xmlns=3D"<a href="">http://www.=</a>
<a href="w3.org/1999/xhtml">w3.org/1999/xhtml</a>"&gt;
&lt;head&gt;
&lt;meta http-equiv=3D"Content-Type" content=3D=
"text/html; charset=3Dutf-8"&gt;
&lt;title&gt;CMS Password Reset&lt;/title&gt;
&lt;/head&gt;=

&lt;body&gt;

&lt;style type=3D"text/css"&gt;
  p { margin-bottom: 1em; }
&lt;/=
style&gt;

&lt;p&gt;Hi you@domain.net,&lt;/p&gt;
&lt;p&gt;You requested a passw=
ord reset for CMS.&lt;/p&gt;
&lt;p&gt;To reset your password click this link:&lt;br /&gt;&lt;a=
 href=3D"<a href="https://www.domain.net/cms/admin.php?menu=3DresetPasswo=" rel="nofollow">https://www.domain.net/cms/admin.php?menu=3DresetPasswo=</a>
rd&amp;userNum=3D1&amp;resetCode=3D0226ab5846b92c5ed0da66b924504297f87abdce"&gt;https:=
//<a href="www.domain.net/cms/admin.php?menu=3DresetPassword&amp;userNum=3D1&amp;=">www.domain.net/cms/admin.php?menu=3DresetPassword&amp;userNum=3D1&amp;=</a>
resetCode=3D0226ab5846b92c5ed0da66b924504297f87abdce&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This requ=
est was made from IP address: (removed)&lt;/p&gt;&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>#2 - Partial Example from Auto Backup v1.04 Plugin:</p>
<pre class="language-markup"><code>--_=_swift_v4_1654624802_b5c4dc98cc1f9bcb6a421e7fe5f9af33_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Automatically generated backup file.

--_=_swift_v4_1654624802_b5c4dc98cc1f9bcb6a421e7fe5f9af33_=_
Content-Type: application/octet-stream;
 name=myweb-v3.56-hourly-14.sql.php.gz
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename=myweb-v3.56-hourly-14.sql.php.gz

H4sIAAAAAAACA+1d63bbyJH+76foYydjKytSAHinbM/IsjxWRpZ1JHqcnChHbgJNsscAGtMAJHP2
5Jx9jf2Xv9nHyLzJPslWNS4ESZAUKNEryXA4Cgl0V3VVfV1d1RegUiHPv/dGHrE4e/a0N+I+gY8r
AkKJJ8VQUocMuM2qT7d2CfvCg13y/ctHjx5VKvAhPdq3GfEDGZpBKBkZCEkCde3Tk97eq6ODi5PT
... (removed large block)

--_=_swift_v4_1654624802_b5c4dc98cc1f9bcb6a421e7fe5f9af33_=_--
</code></pre>
<p>I'm not sure what to do or check. Thanks in advance for any ideas.</p>
<p>~ Deborah</p>]]></description>
          <pubDate>Tue, 07 Jun 2022 11:41:44 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245972#post2245972</guid>
        </item>
              </channel>
    </rss>
  