Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Base64 encoded email body is not decoded #86

Open
terryseah opened this issue May 29, 2018 · 9 comments
Open

Base64 encoded email body is not decoded #86

terryseah opened this issue May 29, 2018 · 9 comments
Labels

Comments

@terryseah
Copy link

The application I am using to send email encodes the email body in base64. An example below is a html email message being sent.

<html><head><title>Title</title></head>
<body>Text goes here</body></html>

However, the web UI does not seem to decode the message, instead, it shows the encoded string
PGh0bWw+PGhlYWQ+PHRpdGxlPlRpdGxlPC90aXRsZT48L2hlYWQ+Cjxib2R5PlRleHQgZ29lcyBoZXJlPC9ib2R5PjwvaHRtbD4K

@terryseah terryseah changed the title Base54 encoded email body is not decoded Base64 encoded email body is not decoded May 29, 2018
@adampresley
Copy link
Contributor

I'll take a look at this.

@adampresley adampresley added the bug label Jun 7, 2018
@adampresley
Copy link
Contributor

Can you provide a sample of how to construct this mail? Please see the below screenshots where I have a Base64 encoded email that is decoding correctly. Perhaps there is a setup step I am missing?

screen shot 2018-06-06 at 9 23 58 pm

screen shot 2018-06-06 at 9 24 26 pm

@terryseah
Copy link
Author

I'm reusing the same code (with some changes) I saw from another issue

using System.Net.Mail;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("<html><head><title>Title</title></head>");
            stringBuilder.Append("<body> Text goes here </body></html>");
            string body = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(stringBuilder.ToString()));

            var message = new MailMessage("from@test.com", "to@test.com")
            {
                Subject = "Test email",
                IsBodyHtml = true,
                Body = body,
                BodyEncoding = Encoding.UTF8
            };

            using (var client = new SmtpClient("localhost", 25))
            {
                client.Send(message);
            }

        }
    }
}

image

@terryseah terryseah reopened this Jun 7, 2018
@adampresley
Copy link
Contributor

OK, thanks for the test code. I'll give that a try.

@MichaelDenholm
Copy link

I'm seeing the same issue without explicitly converting the body to Base64

I am using System.Net.Mail like terryseah, but the messages are constructed with AlternateViews (text/plain and text/html) and there is a jpeg image on the html version.
The AlternateViews are using the default encoding (ASCII)

I'll send some sample code later tonight if that will help

@s00500
Copy link

s00500 commented Dec 2, 2018

Hm I have the same problem with the subject line

UPDATE: This is not true, was just a old version of mailslurper in the docker-mailslurper repo

adampresley added a commit that referenced this issue Apr 7, 2020
…dy-is-not-decoded

Base64 encoded email body is not decoded #86
@optimus-code
Copy link

Are there any intentions to handle base64 decoding for these scenarios? These issues have been around for a long time and it's a relatively simple fix!

This tool WOULD be perfect for my situation if it supported decoding the multipart message, otherwise this tool is useless for my situation.

@ortonomy
Copy link

Did this get fixed? my script is generating emails that produce content with simplied chinese characters and the python mailer defaults to encoding utf8 strings to base64. Mailslurper just displays the base64 body

@Davidos533
Copy link

this docker image marcopas/docker-mailslurper, still have this problem

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

No branches or pull requests

7 participants