ozimov / spring-boot-email-tools

A set of services and tools for sending emails in a Spring Boot 1.5.x application using a Template Engine
Apache License 2.0
194 stars 96 forks source link

Content-Type is set as text/plain, not html, when using Freemarker #55

Open konst123 opened 7 years ago

konst123 commented 7 years ago

I create an Email via DefaultEmail.builder() and send it via emailService.send with a Freemarker template (without attachments). The problem is that the Content-Type is set to text/plain, not html:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_Part_1_600820203.1498641103737"

------=_Part_1_600820203.1498641103737
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!doctype html>
<html>
    <body>

I can also see that the MimeMessage returned from emailService.send has only one part with objectMimeType set to text/plain; charset=UTF-8.

I tried to set customHeaders but it does not help.

robertotru commented 7 years ago

Hey, I have to check. I'll let you know asap

konst123 commented 7 years ago

It is strange, but if I deploy the same app on the server in use text/html:

Content-Type: multipart/mixed; 
    boundary="----=_Part_0_1245359920.1498747402081"
X-Yandex-Forward: 0fdc2ca0db90b35549dc87b16843c851

------=_Part_0_1245359920.1498747402081
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!doctype html>
<html>
    <body>

But when I test the same code locally on my Windows PC, it send it as text/plain as in the example above.

robertotru commented 7 years ago

Is the server running Linux or Windows?

konst123 commented 7 years ago

Linux. It is Google App engine flexible environment.

robertotru commented 7 years ago

Can you provide a reproducible example. I'd like to see if it provides the same output on my Mac

robertotru commented 7 years ago

Closing because of missing feedback

konst123 commented 7 years ago

I think this is the problem described here. https://stackoverflow.com/questions/5028670/how-to-set-mimebodypart-contenttype-to-text-html

It sends html in the prod server, but do not send html in a unit test.

They recommend using MimeMessage.saveChanges()

robertotru commented 7 years ago

@konst123 thanks for poiting to that SO answer. I updated master. Could you try to see if master now solves your issue?

Best Roberto

konst123 commented 7 years ago

Thank you. I tried it but it doesn't help - I have the same result. The problem maybe somewhere else.

drmzperx commented 5 years ago

Hi, I have the same problem. I use the mustache html template example (version 0.6.3). When I use the spring-boot app with locally (mvn appengine:run) the html message shows perfectly. But, when I deploy the app to google app engine, the message show text/plain content-type (in gmail web client). The html template starts with <!doctype html>.

Thanks, Attila

robertotru commented 5 years ago

@drmzperx so it seems a problem of environment configuration. I'm sorry but I can only debug issues on my local environment. I think you will need to understand what's different in the settings in your local env and in the remote one.