1

I'm sending e-mails using this code:

HtmlEmail email = new HtmlEmail();

email.setHostName("webmail.diastecnologia.com.br");
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("marcelo", "senha"));

email.setStartTLSEnabled(bkEmail.getStatusTlsStart());
email.setFrom("marcelo@diastecnologia.com.br", "BKOffice");
email.setSubject("Recuperação de Senha");
email.setHtmlMsg("<html><body><h1>TESTE!!!</h1></body></html>");
email.addTo("marueru@gmail.com", "Maruero");

email.send();

I'm getting two behaviour with the same code. When I run using main(String[] args) it works.

enter image description here

When I run it deployed on Tomcat it does not work.

enter image description here

Someone please help!

Marcelo Dias
  • 409
  • 2
  • 18
  • I see you're reading it through gmail. Please click on the right side next to the `reply` button for the dropdown options, there you will find an option `Show original`. Search for a header called `Content-Type:` inside the RAW email. – grochmal Jun 07 '16 at 23:01
  • Content-Type: text/plain; charset=UTF-8 – Marcelo Dias Jun 08 '16 at 12:26
  • How can a change it to "text/html" ? – Marcelo Dias Jun 08 '16 at 12:26
  • I guess it might be some internal incongruity. Most HTML emails are used with a plain text alternative and i suspect that is from where that `Content-Type` is coming from, i'd add a `email.setTextMsg()` with a plain text alternative. And then move both message calls (`setTextMsg` and `setHtmlMsg`) just before `send()`. – grochmal Jun 08 '16 at 18:43

0 Answers0