SMTPKitten icon indicating copy to clipboard operation
SMTPKitten copied to clipboard

Mail.Content.alternative(emailText, html: emailHtml) Doesn't work correctly

Open thecheatah opened this issue 1 year ago • 1 comments

Describe the bug I assume that Mail.Content.alternative(emailText, html: emailHtml) is suppose to provide both text and HTML and allow the client to decide which one it can display. When I try to use it my Gmail client's raw view of the email looks like this:

--B9D183B2-5135-4FC1-B0EE-3D627C98443F Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8BIT Test email! --B9D183B2-5135-4FC1-B0EE-3D627C98443F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8BIT
  <html> <body>
   Test email! </body> </html> --B9D183B2-5135-4FC1-B0EE-3D627C98443F--


--B9D183B2-5135-4FC1-B0EE-3D627C98443F--

Notice that there is no newline after Content-Transfer-Encoding: 8BIT and before the text "Test email!" for the plain text. This email didn't render within Gmail at all. The body was blank

To Reproduce

    let emailText = """
Test email!
"""
    let emailHtml = """
<html>
<body>
  Test email!
</body>
</html>
"""
    let email = Mail(
      from: .defaultSender,
      to: [MailUser(name: nil, email: email)],
      subject: "This is a Test Email") {
        Mail.Content.alternative(emailText, html: emailHtml)
      }
    try await send(mail: email)

Expected behavior I think what's suppose to happen is that Gmail is suppose to display the HTML version. The Text version should appear for text only clients.

Details:

  • OS: 14.3.1 (23D60)
  • Release 0.2.3
  • SMTP Server exim

Additional context I was playing around with the client and observed this. I don't use this feature, but thought it would help improve the library and maybe highlight other related bugs.

This issue might be related to my other "\n" vs "\r\n" issue.

thecheatah avatar Mar 21 '24 23:03 thecheatah

Is this still valid since 1.0.0-alpha.1

thoven87 avatar Sep 12 '24 01:09 thoven87