This PR fixes the issue where the line breaks on plain text (non-HTML) emails do not show in "HTML" preview. We solve this issue by loosely checking via regex if the message has any open tags <>. We are doing it this way because the other approaches I can think of are not good.
Check if the headers contains Content-Type: text/html - this won't work because some emails are not sent with this header but are still HMTL.
Use a proper HTML/DOM library to test if the message content is a valid HTML - while this will work, I believe it will be overkill and will be another overhead.
So the solution in this PR is to just check if any open tags are present. If yes, then it will assume that the message is an HTML and won't perform nl2br() to the message.
Motivation
Fixes #158.
Testing and procedure
Install WP Mail SMTP (will just be using this to send a test email).
Navigate to Dashboard -> WP Mail SMTP -> Tools -> Email Test, toggle off "HTML" and send the test email. https://a.supportally.com/i/p7qT9y
Description
This PR fixes the issue where the line breaks on plain text (non-HTML) emails do not show in "HTML" preview. We solve this issue by loosely checking via regex if the message has any open tags
<>
. We are doing it this way because the other approaches I can think of are not good.Content-Type: text/html
- this won't work because some emails are not sent with this header but are still HMTL.So the solution in this PR is to just check if any open tags are present. If yes, then it will assume that the message is an HTML and won't perform
nl2br()
to the message.Motivation
Fixes #158.
Testing and procedure
Screenshot
https://a.supportally.com/i/eQowJS