Body: <p>A couple of months ago we upgraded from CiviCRM 5.56 to 5.75 (now at 5.78.3).  Shortly after we started hearing from recipients of our mailings that their messages were corrupt.  Specifically, they were seeing the raw unformatted message, headers and all.  The complaints were coming from people using small ISPs, an outdated email client (like Outlook 2007), or both.  So far no complaints from users of large ISPs (Gmail, Yahoo, etc.).</p>
  <p>I think I have found something that might be a possible culprit.  We normally send HTML formatted messages, and rely on CiviMAIL to supply a plain text &quot;translation&quot;.</p>
  <p>One of the changes (with 5.66 or 5.68 I think) was to change to the new soundasleep/html2text routine.  The old version would add the requisite pair of CRLF elements at the end of the plain text message; the new version does not.  This creates a non-standard MIME separator (RFC 1341) missing a CRLF separator.</p>
  <p><strong>Typical message structure before upgrading beyond CiviCRM 5.56:</strong></p>
  <pre><code>Content-Type: multipart/alternative; boundary=&quot;=_af89c1362d6a54b9b89bded072a4ff81&quot;
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/plain; charset=utf-8
  
  Plain text message
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/html; charset=utf-8
  
  &lt;HTML formated message&gt;
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  </code></pre>
  <p><strong>And now after:</strong></p>
  <pre><code>Content-Type: multipart/alternative; boundary=&quot;=_af89c1362d6a54b9b89bded072a4ff81&quot;
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/plain; charset=utf-8
  
  Plain text message &lt;-- note no CRLF follows
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/html; charset=utf-8
  
  &lt;HTML formated message&gt;
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  </code></pre>
  <p>I'm only guessing that this is the cause of the garbled/misinterpreted messages since I can't repeat the problem on my own email providers.</p>
  <p>We're running on Drupal 7.101, PHP 8.3.12, MySQL 5.7.44. Outbound mailer is mail() (as opposed to SMTP or sendmail).</p>
  <p><strong>UPDATE</strong></p>
  <p>Changing the outbound mailer from mail() to SMTP made the problem go away.  The people who had been receiving garbled messages are now seeing properly formatted messages.</p>
  <p>As part of the process of upgrading CiviCRM, it was necessary to upgrade from PHP 7 to PHP 8. This message <a href="https://civicrm.stackexchange.com/questions/45782/html-and-email-content-and-no-graphics-or-formatting-in-emails">https://civicrm.stackexchange.com/questions/45782/...</a> offered a clue. It would seem that the PHP mail() function in PHP 8.3 is still broken. Big mail providers like Gmail and Yahoo must have implemented a workaround, but smaller providers have not.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-11-14T01:05:17.633Z
Comments.Text: my reading of the other ticket, and then to https://lab.civicrm.org/dev/core/-/issues/4913, implies this was fixed a while back
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-11-14T17:02:59.317Z
Comments.Text: I read that too, which led me to look elsewhere. I was grasping at straws when I switched to SMTP and surprised at the result. If eliminating mail() solved the problem, then it seems to me that the bug has not been fixed.
Comments.UserDisplayName: charlie
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-11-14T18:34:03.160Z
Comments.Text: you are welcome to add your experience as a comment on that issue (even if it is closed). we use mail() for nearly all our sites and not noticed problems
Comments.UserDisplayName: petednz - fuzion
Tags: <civimail><drupal-7><php8>
Title: Incorrect MIME boundary and garbled messages
ThreadText: # Incorrect MIME boundary and garbled messages
  
  (Asked by: username_0 on 2024-11-04)
  
  A couple of months ago we upgraded from CiviCRM 5.56 to 5.75 (now at 5.78.3). Shortly after we started hearing from recipients of our mailings that their messages were corrupt. Specifically, they were seeing the raw unformatted message, headers and all. The complaints were coming from people using small ISPs, an outdated email client (like Outlook 2007), or both. So far no complaints from users of large ISPs (Gmail, Yahoo, etc.).
  
  I think I have found something that might be a possible culprit. We normally send HTML formatted messages, and rely on CiviMAIL to supply a plain text "translation".
  
  One of the changes (with 5.66 or 5.68 I think) was to change to the new soundasleep/html2text routine. The old version would add the requisite pair of CRLF elements at the end of the plain text message; the new version does not. This creates a non-standard MIME separator (RFC 1341) missing a CRLF separator.
  
  **Typical message structure before upgrading beyond CiviCRM 5.56:**
  
  ```
  Content-Type: multipart/alternative; boundary="=_af89c1362d6a54b9b89bded072a4ff81"
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/plain; charset=utf-8
  
  Plain text message
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/html; charset=utf-8
  
  <HTML formated message>
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  
  ```
  
  **And now after:**
  
  ```
  Content-Type: multipart/alternative; boundary="=_af89c1362d6a54b9b89bded072a4ff81"
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/plain; charset=utf-8
  
  Plain text message <-- note no CRLF follows
  --=_af89c1362d6a54b9b89bded072a4ff81
  Content-Transfer-Encoding: 8bit
  Content-Type: text/html; charset=utf-8
  
  <HTML formated message>
  
  --=_af89c1362d6a54b9b89bded072a4ff81
  
  ```
  
  I'm only guessing that this is the cause of the garbled/misinterpreted messages since I can't repeat the problem on my own email providers.
  
  We're running on Drupal 7.101, PHP 8.3.12, MySQL 5.7.44. Outbound mailer is mail() (as opposed to SMTP or sendmail).
  
  **UPDATE**
  
  Changing the outbound mailer from mail() to SMTP made the problem go away. The people who had been receiving garbled messages are now seeing properly formatted messages.
  
  As part of the process of upgrading CiviCRM, it was necessary to upgrade from PHP 7 to PHP 8. This message [https://civicrm.stackexchange.com/questions/45782/...](https://civicrm.stackexchange.com/questions/45782/html-and-email-content-and-no-graphics-or-formatting-in-emails) offered a clue. It would seem that the PHP mail() function in PHP 8.3 is still broken. Big mail providers like Gmail and Yahoo must have implemented a workaround, but smaller providers have not.
  
  **Tags:** civimail, drupal-7, php8
  
  > **Comments:**
  > **username_1**: my reading of the other ticket, and then to https://lab.civicrm.org/dev/core/-/issues/4913, implies this was fixed a while back  
  > **username_0**: I read that too, which led me to look elsewhere. I was grasping at straws when I switched to SMTP and surprised at the result. If eliminating mail() solved the problem, then it seems to me that the bug has not been fixed.  
  > **username_1**: you are welcome to add your experience as a comment on that issue (even if it is closed). we use mail() for nearly all our sites and not noticed problems  
  
  ---
  
  ## 0 answers
  
  