Open adamaltman opened 9 years ago
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?
Right now it happens with all HTML messages.
Ok thanks, I'll have another look
Out of interest, do you know if the SMTP client is using pipelining?
Ian - I'm not sure. The client is a php web application. The library it uses for email is: http://swiftmailer.org/
No problem, thanks, I'll see if I can reproduce it a bit more consistently.
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.
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
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!
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!!).
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.
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.
Think I've got it this time, but I'll keep the issue open for now
Great work Ian. Works for me in 0.1.3
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!
Thanks @JanStevens, I'll have a look asap.
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?
Same problem here. All my emails seen as plainText. It would be the perfect tool otherwise
Thanks for the updates @chuntley @4lyn - could you provide example SMTP messages plus the log output for MailHog receiving them.
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
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
+1 Happens for me too
+1 For me too with the basic example from PHP website Example #4 Sending HTML email.
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
Nice shot ! It works for me now. Thanks a lot !
Maybe we can add an other control over the content (html tags) if the Content-type is blank ?
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?
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#L458
Guys, it's still not fixed. Can anyone fix this please?
How to find controllers.js locally (Ubuntu)? Can't find it. Could someone help me please?
Still interested in a fix of this one...
How could I help?
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?
Sorry, thought I'd fixed this... https://github.com/mailhog/MailHog/issues/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!)
Any news on this? Also seeing everything in plain-text
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?
I'm also seeing HTML emails in plain text.
I have the same problem with HTML emails.
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?
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
Oh man! I installed MailHog just to work on Woocommerce emails and now I find this issue! ðŸ˜
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/
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.
Hi, I'm facing similar issue as the mail body is shown encoded. I'm using mailer lib from dart
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
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.
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.
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"
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
try to prepand body an "\r\n". in my case mailhog is now extracting data correct from message source....
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.
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.
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
Also having the same issue with nodemailer: ^6.7.8
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: