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

Headers are treated case sensitively #162

Open
GUI opened this issue Jul 28, 2017 · 2 comments
Open

Headers are treated case sensitively #162

GUI opened this issue Jul 28, 2017 · 2 comments
Labels

Comments

@GUI
Copy link

GUI commented Jul 28, 2017

If MailHog receives messages where the headers aren't in the expected case, then MailHog's interface doesn't display the message properly. For example, if the headers are all lower case (so 'subject' instead of 'Subject'), then the to/from, subject, and HTML message parsing doesn't work as expected.

  • Here's a quick example using mhsendmail:

    (
    echo "from: me@xyz.com"
    echo "to: them@xyz.com"
    echo "mime-version: 1.0"
    echo "content-type: multipart/alternative; "
    echo ' boundary="some.unique.value.ABC123/server.xyz.com"'
    echo "subject: Test HTML e-mail."
    echo ""
    echo "This is a MIME-encapsulated message"
    echo ""
    echo "--some.unique.value.ABC123/server.xyz.com"
    echo "content-type: text/html"
    echo ""
    echo "<html>
    <head>
    <title>HTML E-mail</title>
    </head>
    <body>
    <a href='http://www.google.com'>Click Here</a>
    </body>
    </html>"
    echo "--some.unique.value.ABC123/server.xyz.com--"
    ) | mhsendmail test@mailhog.local
    

    In the inbox this message shows up as being from {{ getSender(message) }}, and contains a blank subject. The actual message shows up like this:

    lower-case-headers
  • If I use the more standard title-case for the headers, then this same test works as expected:

    (
    echo "From: me@xyz.com"
    echo "To: them@xyz.com"
    echo "MIME-Version: 1.0"
    echo "Content-Type: multipart/alternative; "
    echo ' boundary="some.unique.value.ABC123/server.xyz.com"'
    echo "Subject: Test HTML e-mail."
    echo ""
    echo "This is a MIME-encapsulated message"
    echo ""
    echo "--some.unique.value.ABC123/server.xyz.com"
    echo "Content-Type: text/html"
    echo ""
    echo "<html>
    <head>
    <title>HTML E-mail</title>
    </head>
    <body>
    <a href='http://www.google.com'>Click Here</a>
    </body>
    </html>"
    echo "--some.unique.value.ABC123/server.xyz.com--"
    ) | mhsendmail test@mailhog.local
    

    Which shows up as:

    title-case-headers

I saw a few explicit headers are being treated in a case insensitive fashion, but this doesn't extend to all headers, like "From," "To," "Subject," and "Content-Type." I poked around a bit to see about submitting a pull request, but I wasn't sure the preferred way to go about it. I saw various things in the UI are expecting title-cased headers, so maybe it would be simplest to have the server normalize all the values to title-case to minimize the UI changes needed?

I'm not sure how common this is, but headers should be case insensitive according to the spec. I encountered this since LuaSocket's SMTP client actually does lowercase all the headers before sending.

@robinknaapen
Copy link

I have a similar kind of issue. {{ getSender(message) }} shows up when I don't fill the message's body

No body
image
image
image

With body
image
image
image

@dimitropoulos
Copy link

2 years later, this is still a bug, from what I can tell mailhog/MailHog-UI#29 is still open. @ian-kent what steps need to occur to get this fixed?

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

No branches or pull requests

4 participants