Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

html email rendering as plain text #22

Open
adamaltman opened this issue Jan 3, 2015 · 57 comments
Open

html email rendering as plain text #22

adamaltman opened this issue Jan 3, 2015 · 57 comments
Labels

Comments

@adamaltman
Copy link

When MailHog receives an email, which is html, it renders it as "plain text". I don't know why this happens, and how to render it as html.

Here is an example of part of the headers, as well as a screenshot:

Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=utf-8 

selection_218

@ian-kent ian-kent added the bug label Jan 3, 2015
@ian-kent
Copy link
Member

ian-kent commented Jan 3, 2015

Thanks @adamaltman, does this happen with all HTML messages or just occasionally?

I can sort of reproduce it, but only when the HTML email follows a plain text email. When it happens, the broken HTML message contains the previous plain text email at the start (and I assume the headers), which is why MIME parsing fails. I'll fix that anyway, but does it sound like it might be the same bug?

@adamaltman
Copy link
Author

Right now it happens with all HTML messages.

@ian-kent
Copy link
Member

ian-kent commented Jan 4, 2015

Ok thanks, I'll have another look

Out of interest, do you know if the SMTP client is using pipelining?

@adamaltman
Copy link
Author

Ian - I'm not sure. The client is a php web application. The library it uses for email is: http://swiftmailer.org/

@ian-kent
Copy link
Member

ian-kent commented Jan 5, 2015

No problem, thanks, I'll see if I can reproduce it a bit more consistently.

@jygastaud
Copy link

I have the same issue with a Drupal (PHP) website + PHPMailer library.
Mails in (real) inbox as Gmail are display fine but MailHog seems not to understand it.
Plain text with HTLML structure are displayed.

@ian-kent
Copy link
Member

ian-kent commented Jan 7, 2015

Would either of you be able to provide MailHog logs demonstrating the bug so I can replay the SMTP conversation against my MailHog to reproduce it?

If you don't want to post it here, if possible could you e-mail them to me instead? email@iankent.co.uk

Thanks

@JanStevens
Copy link

I have the same issue using a Rails application, i'm willing to provide logs if you guide me to their location or how to log them

Thanks for this awesome program, mailcatcher is sadly not really maintained and doesn't work for ruby 2.2.0 so this is a very good alternative!

@ian-kent
Copy link
Member

ian-kent commented Jan 8, 2015

Thanks @JanStevens, that would definitely be useful!

It'll depend on how you're running MailHog - if its from the command line, the logs should be going to STDOUT, so redirecting to file or piping to tee should work.

Let me know if its Docker and I'll give it a go, to be honest I hadn't even considered how logging would work for the Docker container builds (and I'm no Docker expert!!).

@ian-kent
Copy link
Member

ian-kent commented Jan 8, 2015

I'll keep this open for now, but I hope the latest release has fixed it - but couldn't reproduce it reliably anyway so not entirely sure.

@ian-kent ian-kent reopened this Jan 8, 2015
@jygastaud
Copy link

Sadly, no. At least in my case.

MailHog version: 0.1.2 Linux amd64
OS: Debian 7

I will sent you a log file in a minute.

@ian-kent
Copy link
Member

ian-kent commented Jan 8, 2015

Think I've got it this time, but I'll keep the issue open for now

@ian-kent ian-kent reopened this Jan 8, 2015
@jygastaud
Copy link

Great work Ian.
Works for me in 0.1.3

@JanStevens
Copy link

Oke still doesnt work for me, I've send you an email with the output. If you need more information then please let me know! thanks!

@ian-kent
Copy link
Member

ian-kent commented Jan 9, 2015

Thanks @JanStevens, I'll have a look asap.

@chuntley
Copy link

I'm having this same issue. The headers look correct but the email is being rendered in plain text. Is there a way to force all emails to be rendered as HTML as a workaround?

@4lyn
Copy link

4lyn commented Mar 1, 2016

Same problem here. All my emails seen as plainText. It would be the perfect tool otherwise

@ian-kent
Copy link
Member

Thanks for the updates @chuntley @4lyn - could you provide example SMTP messages plus the log output for MailHog receiving them.

@4lyn
Copy link

4lyn commented Mar 25, 2016

Simple php code :

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: Test <noreply@test.fr>';
mail('test@test.fr', 'Test html email', '<html><body>This should be html email<br/>Thank you</body></html>', $headers)

I only see the "Plain text" and "Source" Tab in the MailHog web interface

MailHog log :

2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Starting session
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: INVALID] Started session, switching to ESTABLISH state
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 35 bytes: '220 mailhog.example ESMTP MailHog\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 16 bytes: 'EHLO localhost\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: ESTABLISH] Processing line: EHLO localhost
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: ESTABLISH] In state 1, got command 'EHLO', args 'localhost'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: ESTABLISH] Got EHLO command, switching to MAIL state
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 21 bytes: '250-Hello localhost\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 16 bytes: '250-PIPELINING\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 16 bytes: '250 AUTH PLAIN\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 28 bytes: 'MAIL FROM:www-data@ginza\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] Processing line: MAIL FROM:www-data@ginza
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] In state 6, got command 'MAIL', args 'FROM:www-data@ginza'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] Got MAIL command, switching to RCPT state
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 30 bytes: '250 Sender www-data@ginza ok\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 24 bytes: 'RCPT TO:test@test.fr\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] Processing line: RCPT TO:test@test.fr
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] In state 7, got command 'RCPT', args 'TO:test@test.fr'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] Got RCPT command
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 31 bytes: '250 Recipient test@test.fr ok\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 6 bytes: 'DATA\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] Processing line: DATA
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] In state 7, got command 'DATA', args ''
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: RCPT] Got DATA command, switching to DATA state
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 37 bytes: '354 End data with .\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 251 bytes: 'To: test@test.fr\r\nSubject: Test html email\r\nX-PHP-Originating-Script: 1000:functions.php\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\nFrom: Test noreply@test.fr\r\n\r\nThis should be html email
Thank you\r\n.\r\n'
2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: DATA] Got EOF, storing message and switching to MAIL state
2016/03/25 11:19:58 Parsing Content from string: 'To: test@test.fr
Subject: Test html email
X-PHP-Originating-Script: 1000:functions.php
MIME-Version: 1.0
Content-type: text/html; charset=UTF-8
From: Test noreply@test.fr

This should be html email
Thank you' 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Storing message IWU1gnlVnECkLLBj2hXoMRBD8ycJRYAnjMRiZFl9OrQ=@mailhog.example 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 80 bytes: '250 Ok: queued as IWU1gnlVnECkLLBj2hXoMRBD8ycJRYAnjMRiZFl9OrQ=@mailhog.example\r\n' Got message in APIv1 event stream 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Received 6 bytes: 'QUIT\r\n' 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] Processing line: QUIT 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] In state 6, got command 'QUIT', args '' 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] [PROTO: MAIL] Got QUIT verb, staying in MAIL state 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Sent 9 bytes: '221 Bye\r\n' 2016/03/25 11:19:58 [SMTP 127.0.0.1:50089] Session ended Sending content: { "ID": "IWU1gnlVnECkLLBj2hXoMRBD8ycJRYAnjMRiZFl9OrQ=@mailhog.example", "From": { "Relays": null, "Mailbox": "www-data", "Domain": "ginza", "Params": "" }, "To": [ { "Relays": null, "Mailbox": "test", "Domain": "test.fr", "Params": "" } ], "Content": { "Headers": { "Content-type": [ "text/html; charset=UTF-8" ], "From": [ "Test \u003cnoreply@test.fr\u003e" ], "MIME-Version": [ "1.0" ], "Message-ID": [ "IWU1gnlVnECkLLBj2hXoMRBD8ycJRYAnjMRiZFl9OrQ=@mailhog.example" ], "Received": [ "from localhost by mailhog.example (Go-MailHog)\r\n id IWU1gnlVnECkLLBj2hXoMRBD8ycJRYAnjMRiZFl9OrQ=@mailhog.example; Fri, 25 Mar 2016 11:19:58 +0100" ], "Return-Path": [ "\u003cwww-data@ginza\u003e" ], "Subject": [ "Test html email" ], "To": [ "test@test.fr" ], "X-PHP-Originating-Script": [ "1000:functions.php" ] }, "Body": "\u003chtml\u003e\u003cbody\u003eThis should be html email\u003cbr/\u003eThank you\u003c/body\u003e\u003c/html\u003e", "Size": 246, "MIME": null }, "Created": "2016-03-25T11:19:58.484317981+01:00", "MIME": null, "Raw": { "From": "www-data@ginza", "To": [ "test@test.fr" ], "Data": "To: test@test.fr\r\nSubject: Test html email\r\nX-PHP-Originating-Script: 1000:functions.php\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\nFrom: Test \u003cnoreply@test.fr\u003e\r\n\r\n\u003chtml\u003e\u003cbody\u003eThis should be html email\u003cbr/\u003eThank you\u003c/body\u003e\u003c/html\u003e", "Helo": "localhost" } }

@hugochinchilla
Copy link

+1 Happens for me too

@crazy-max
Copy link

+1 For me too with the basic example from PHP website Example #4 Sending HTML email.

mail

@akreal
Copy link

akreal commented May 26, 2016

I think the problem is that some messages have Content-type header, while MailHog checks only Content-Type one:
https://github.com/mailhog/MailHog-UI/blob/master/assets/js/controllers.js#L461

@4lyn
Copy link

4lyn commented May 27, 2016

Nice shot !
It works for me now. Thanks a lot !

@crazy-max
Copy link

crazy-max commented May 28, 2016

Maybe we can add an other control over the content (html tags) if the Content-type is blank ?

@jehon
Copy link

jehon commented Sep 12, 2016

I have the same problem with a Drupal installation sending emails.

Looking a bit in the Drupal system, I see that it send content-type with a lower "t".

Is it possible to fix this?

@nortmas
Copy link

nortmas commented Dec 4, 2016

Can you fix this line - https://github.com/mailhog/MailHog-UI/blob/master/assets/js/controllers.js#L458

Instead of this:
if (message.Content.Headers && message.Content.Headers["Content-Type"] && message.Content.Headers["Content-Type"][0].match("text/plain")) {

need to use something like this:

if ( message.Content.Headers && ( (message.Content.Headers["Content-Type"] && message.Content.Headers["Content-Type"][0].match("text/plain")) || (message.Content.Headers["Content-type"] && message.Content.Headers["Content-type"][0].match("text/plain")) ) ) {

Because some messages have "Content-type" header, while MailHog checks only "Content-Type"

Also I can't find controllers.js locally (Ubuntu) to fix this file. Do you know the location where I should search?

@ian-kent
Copy link
Member

ian-kent commented Dec 4, 2016

Sorry, thought I'd fixed this... #113 turns out it was a different bug!

controllers.js is inside MailHog-UI - https://github.com/mailhog/MailHog-UI/blob/master/assets/js/controllers.js

there's a bunch of places where it treats headers incorrectly - more than happy to accept a PR to fix this one, but otherwise I'll have a look at cleaning that mess up asap!

edit: afaik, to be RFC compliant in its header handling it can just lowercase everything before the comparison/lookup (I think it was defined in RFC822, but seems to be missing from the updated RFC2822 and RFC5322 - if anyone knows where its now covered it'd be a great help!)

@timmetj
Copy link

timmetj commented Feb 2, 2017

Any news on this? Also seeing everything in plain-text

@Barry-Fisher
Copy link

I'm finding that HTML tab doesn't display on version 0.2.1-4 - only the Plain text and Source tabs. The email body looks like:

This is a multi-part message in MIME format.

--57201bf7ced0e78fd2e77e80d390449b59d746de9
Content-Type:multipart/alternative;
boundary="99569b95c2565c7786d9de5a6b102e5715176f928"
Content-Transfer-Encoding:8bit

--99569b95c2565c7786d9de5a6b102e5715176f928
Content-Type:text/plain; charset=utf-8
Content-Disposition:inline
Content-Transfer-Encoding:8bit

CLIPPED MESSAGE

--99569b95c2565c7786d9de5a6b102e5715176f928
Content-Type:text/html; charset=utf-8
Content-Disposition:inline
Content-Transfer-Encoding:8Bit

CLIPPED MESSAGE

--99569b95c2565c7786d9de5a6b102e5715176f928--

--57201bf7ced0e78fd2e77e80d390449b59d746de9--

The Content-Type header appears to have the right case to match the javascript.
I'm also using Drupal and the PHPMailer library.

Does anything appear glaringly obvious that I'm missing here?

@FellowshipAgency
Copy link

I'm also seeing HTML emails in plain text.

@vukomir
Copy link

vukomir commented May 3, 2018

I have the same problem with HTML emails.

@hellerbenjamin
Copy link

Experiencing this consistently today with a Woocommerce site. If I have time I will help troubleshoot but does anyone want logs if I supply them?

@webdobe
Copy link

webdobe commented Mar 31, 2019

I am getting this as well with a Drupal 8 docker install. Regardless if I send in html or not. Been debugging, but not getting anywhere. I changed some info to remain anonymous, I see the mailhog.example.. not sure If that is causing the issue?

2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Starting session
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: INVALID] Started session, switching to ESTABLISH state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 35 bytes: '220 mailhog.example ESMTP MailHog\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 19 bytes: 'EHLO cbd2025bd2d3\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: ESTABLISH] Processing line: EHLO cbd2025bd2d3
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: ESTABLISH] In state 1, got command 'EHLO', args 'cbd2025bd2d3'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: ESTABLISH] In ESTABLISH state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: ESTABLISH] Got EHLO command, switching to MAIL state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 24 bytes: '250-Hello cbd2025bd2d3\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 16 bytes: '250-PIPELINING\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 16 bytes: '250 AUTH PLAIN\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 40 bytes: 'MAIL FROM:<noreply@XXX.com>\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] Processing line: MAIL FROM:<noreply@XXX.com>
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] In state 6, got command 'MAIL', args 'FROM:<noreply@XXX.com>'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] In MAIL state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] Got MAIL command, switching to RCPT state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 42 bytes: '250 Sender noreply@XXX.com ok\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 25 bytes: 'RCPT TO:<jesse@XXX.com>\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] Processing line: RCPT TO:<jesse@XXX.com>
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] In state 7, got command 'RCPT', args 'TO:<jesse@XXX.com>'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] In RCPT state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] Got RCPT command
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 32 bytes: '250 Recipient jesse@XXX.com ok\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 6 bytes: 'DATA\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] Processing line: DATA
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] In state 7, got command 'DATA', args ''
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] In RCPT state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: RCPT] Got DATA command, switching to DATA state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 37 bytes: '354 End data with <CR><LF>.<CR><LF>\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 939 bytes: 'To: jesse@XXX.com\r\nSubject: An administrator created an account for you at My Website\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes\r\nContent-Transfer-Encoding: 8Bit\r\nX-Mailer: Drupal\r\nSender: noreply@XXX.com\r\nFrom: My Website <noreply@XXX.com>\r\nReply-to: noreply@XXX.com\r\n\r\ntest,\r\n\r\nA site administrator at My Website has created an account for you. You\r\nmay now log in by clicking this link or copying and pasting it to your\r\nbrowser:\r\n\r\nhttps://www.XXX.com/user/reset/31/1554073132/v1aMTWcBUVq33Y1u5mI53zGayTlmDKk0ghT7XXQlGpk\r\n\r\nThis link can only be used once to log in and will lead you to a page where\r\nyou can set your password.\r\n\r\nAfter setting your password, you will be able to log in at\r\nhttps://www.XXX.com/user in the future using:\r\n\r\nusername: test\r\npassword: Your password\r\n\r\n--  My Website team\r\n\r\n.\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: DATA] Got EOF, storing message and switching to MAIL state
2019/03/31 22:58:53 Parsing Content from string: 'To: jesse@XXX.com

Subject: An administrator created an account for you at My Website

MIME-Version: 1.0

Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes

Content-Transfer-Encoding: 8Bit

X-Mailer: Drupal

Sender: noreply@XXX.com

From: My Website <noreply@XXX.com>

Reply-to: noreply@XXX.com



test,



A site administrator at My Website has created an account for you. You

may now log in by clicking this link or copying and pasting it to your
�




https://www.XXX.com/user/reset/31/1554073132/v1aMTWcBUVq33Y1u5mI53zGayTlmDKk0ghT7XXQlGpk



This link can only be used once to log in and will lead you to a page where

you can set your password.



After setting your password, you will be able to log in at

https://www.XXX.com/user in the future using:



username: test

password: Your password



--  My Website team

'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Storing message Or9hsMg92pBJ2WF0V2VjPsTELraP4xQH3lhj5K_iyN0=@mailhog.example
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 80 bytes: '250 Ok: queued as Or9hsMg92pBJ2WF0V2VjPsTELraP4xQH3lhj5K_iyN0=@mailhog.example\r\n'
Got message in APIv2 websocket channel
[APIv2] BROADCAST /api/v2/websocket
Got message in APIv1 event stream
Sending content: {
  "ID": "Or9hsMg92pBJ2WF0V2VjPsTELraP4xQH3lhj5K_iyN0=@mailhog.example",
  "From": {
    "Relays": null,
    "Mailbox": "noreply",
    "Domain": "XXX.com",
    "Params": ""
  },
�
[
    {
      "Relays": null,
      "Mailbox": "jesse",
      "Domain": "XXX.com",
      "Params": ""
    }
  ],
  "Content": {
    "Headers": {
      "Content-Transfer-Encoding": [
        "8Bit"
      ],
      "Content-Type": [
        "text/plain; charset=UTF-8; format=flowed; delsp=yes"
      ],
      "From": [
        "My Website \u003cnoreply@XXX.com\u003e"
      ],
      "MIME-Version": [
        "1.0"
      ],
      "Message-ID": [
        "Or9hsMg92pBJ2WF0V2VjPsTELraP4xQH3lhj5K_iyN0=@mailhog.example"
      ],
      "Received": [
        "from cbd2025bd2d3 by mailhog.example (MailHog)\r\n          id Or9hsMg92pBJ2WF0V2VjPsTELraP4xQH3lhj5K_iyN0=@mailhog.example; Sun, 31 Mar 2019 22:58:53 +0000"
      ],
      "Reply-to": [
        "noreply@XXX.com"
      ],
      "Return-Path": [
        "\u003cnoreply@XXX.com\u003e"
      ],
      "Sender": [
        "noreply@XXX.com"
      ],
      "Subject": [
        "An administrator created an account for you at My Website"
      ],
      "To": [
        "jesse@XXX.com"
      ],
      "X-Mailer": [
        "Drupal"
      ]
    },
    "Body": "test,\r\n\r\nA site administrator at My Website has created an account for you. You\r\nmay now log in by clicking this link or copying and pasting it to your\r\nbrowser:\r\n\r\nhttps://www.XXX.com/user/reset/31/1554073132/v1aMTWcBUVq33Y1u5mI53zGayTlmDKk0ghT7XXQlGpk\r\n\r\nThis link can only be used once to log in and will lead you to a page where\r\nyou can set your password.\r\n\r\nAfter setting your password, you will be able to log in at\r\nhttps://www.XXX.com/user in the future using:\r\n\r\nusername: test\r\npassword: Your password\r\n\r\n--  My Website team\r\n",
    "Size": 934,
    "MIME": null
  },
  "Created": "2019-03-31T22:58:53.606873215Z",
  "MIME": null,
  "Raw": {
    "From": "noreply@XXX.com",
    "To": [
      "jesse@XXX.com"
    ],
    "Data": "To: jesse@XXX.com\r\nSubject: An administrator created an account for you at My Website\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes\r\nContent-Transfer-Encoding: 8Bit\r\nX-Mailer: Drupal\r\nSender: noreply@XXX.com\r\nFrom: My Website \u003cnoreply@XXX.com\u003e\r\nReply-to: noreply@XXX.com\r\n\r\ntest,\r\n\r\nA site administrator at My Website has created an account for you. You\r\nmay now log in by clicking this link or copying and pasting it to your\r\nbrowser:\r\n\r\nhttps://www.XXX.com/user/reset/31/1554073132/v1aMTWcBUVq33Y1u5mI53zGayTlmDKk0ghT7XXQlGpk\r\n\r\nThis link can only be used once to log in and will lead you to a page where\r\nyou can set your password.\r\n\r\nAfter setting your password, you will be able to log in at\r\nhttps://www.XXX.com/user in the future using:\r\n\r\nusername: test\r\npassword: Your password\r\n\r\n--  My Website team\r\n",
    "Helo": "cbd2025bd2d3"
  }
}

[APIv1] BROADCAST /api/v1/events
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Received 6 bytes: 'QUIT\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] Processing line: QUIT
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] In state 6, got command 'QUIT', args ''
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] [PROTO: MAIL] Got QUIT verb, staying in MAIL state
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Sent 9 bytes: '221 Bye\r\n'
2019/03/31 22:58:53 [SMTP 172.18.0.36:51742] Session ended

@KoolPal
Copy link

KoolPal commented May 27, 2019

Oh man! I installed MailHog just to work on Woocommerce emails and now I find this issue! 😭

@hellerbenjamin
Copy link

Oh man! I installed MailHog just to work on Woocommerce emails and now I find this issue! '

This might help in the meantime
https://wordpress.org/plugins/woo-preview-emails/

@KoolPal
Copy link

KoolPal commented May 28, 2019

Oh man! I installed MailHog just to work on Woocommerce emails and now I find this issue! '

This might help in the meantime
https://wordpress.org/plugins/woo-preview-emails/

@hellerbenjamin Thanks I will use this.

@e-belair
Copy link

e-belair commented Mar 7, 2020

Hi, I'm facing similar issue as the mail body is shown encoded. I'm using mailer lib from dart
image
image

@smustgrave
Copy link

I'm also experiencing this issue in Drupal if anyone has any suggestions. I'm using https://www.drupal.org/project/swiftmailer to send HTML emails but no luck.
Headers being generated

Content-Transfer-Encoding 8Bit
text/plain; charset=UTF-8; format=flowed; delsp=yes
NASA Drupal Demo admin@example.com
1.0
jkNuxytJS1Phvb8xbtIOtuJ50vNV6xXZ7MPBWZLGO0A=@email.mailhog.lando
from localhost by email.mailhog.lando (MailHog) id jkNuxytJS1Phvb8xbtIOtuJ50vNV6xXZ7MPBWZLGO0A=@email.mailhog.lando; Thu, 21 Jan 2021 02:31:12 +0000
admin@example.com
admin@example.com
Article: Test updated
something@test.com
Drupal

@3pdev-alex
Copy link

Using MailHog with plain PHP and having the same issue. Using Content-Type: text/html;charset=utf-8 and all emails are coming in as plain text instead of HTML.

@vandijkstef
Copy link

Having the same issue also using UTF-8. Interesting; The 'MIME' tab shows and it shows each part as 'unknown'. When downloading the email as EML file, and opening it in apple mail, it renders as expected.

I'd love to drop a mailhog version, but 'mailhog --version' doesn't give a number, its blank.

@nkboscia
Copy link

Same issue. Using multi-type emails and it doesn't display the HTML tab at all and the MIME type just gives an error: Error: null is not an object (evaluating 'data.MIME.Parts.length')

Content-Type: multipart/alternative; boundary="1623876169.D35aAB6D0.32925"; charset="us-ascii"
MIME-Version: 1.0

MIME-Version: 1.0
Content-Type: text/html; charset="UTF-8"

MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"

@nkboscia
Copy link

nkboscia commented Jun 23, 2021

I put a paid bounty on this in hopes it'll get bumped in priority.

https://www.bountysource.com/issues/7463217-html-email-rendering-as-plain-text

@tecbird
Copy link

tecbird commented Aug 17, 2021

try to prepand body an "\r\n".
in my case mailhog is now extracting data correct from message source....

@nkboscia
Copy link

nkboscia commented Sep 16, 2021

The mail receive identifies to parse on the boundary just fine, but the web interface just throws everything into the plain text tab and ignores the boundary and Content-Type headers.

@leymannx
Copy link

Colleague of mine had the problem with Swiftmailer/Drupal. When they changed the "Sender" to use the "Default PHP Mailer" and keep just the "Formatter" using "Swiftmailer" it suddenly worked.

2022-02-11 at 12 07

@stefumies
Copy link

This is still an issue in Summer 2022, I cant see how this will allow us to continue with Mailhog. Any updates? I have the issue from nodemailer

@michaeljauk
Copy link

Also having the same issue with nodemailer: ^6.7.8

@cluongdp
Copy link

I'm seeing this issue still as of 1/12/2023, although my Plain text tab doesnt even populate:

image

@datmt
Copy link

datmt commented Jan 16, 2023

For people who are using javax.mail, make sure to set the content type right before Transport.send.

msg.setHeader("Content-Type", "text/html; charset=utf-8");
Transport.send(msg);

This is probably it's your mail library problem, not mailhog's problem. Make sure to debug and find out where the content type header is reset to text/plain.

Best of luck!

@jeff-sweetjacket
Copy link

In case it helps - I was experiencing the same using spring and JavaMailSender. Mailhog would not render the html.

The email was being sent as Content-Transfer-Encoding: quoted-printable which ends up inserting a bunch of "3D"s into the html which I initially thought was the problem. After doing some more reading I realized that quoted-printable was correct and wasn't the issue.

I finally realized there was a leftover thymeleaf tag in the html as I previously had been using thymeleaf to populate it. Looking at the source of the email in mailhog this is what the offending tag looked like:

<div th:text=3D"${subject}" th:remove=3D"tag"/>

After removing it mailhog was able to render it as html without issue. So perhaps there's a problem if your html has either:

  • An invalid html attribute like th:text
  • A $ sign
  • A { bracket

Just a guess but at least removing the tag got the html rendering.

@jeff-sweetjacket
Copy link

Actually after doing a little bit more investigation I think it may be an iframe rendering issue. Mailhog (correctly) iframes the email body and inspecting the iframe in chrome developer tools shows that the html is there and being rendered inside the iframe. However, the height of the iframe is 0. So perhaps it's just chrome refusing to display some invalid html inside the iframe? Again, just a guess.

@AnmolVerma404
Copy link

I was having the same issue, my HTML was not rendering but when I add space between Content-type and text/html it started rendering HTML too.
Old

$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

New

$headers .= "Content-type: text/html;charset=UTF-8" . "\r\n";

@e-belair
Copy link

e-belair commented Oct 13, 2023

Mailhog is not actively maintained, I recommend switching to https://github.com/axllent/mailpit

@jeff-hrzap
Copy link

Agreed with e-belair. Mailpit.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests