• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail API HTML rendering problems with Tomcat Web Server  RSS feed

 
Rahul Chaitanya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using the below code for sending out an email in HTML format but the below code is working fine and sending email in proper HTML format, if I run the app as a normal java application. But if I run the same code over tomcat web server, then the email content seems to be extremely wrired format and it isn't in HTML manner.

Here is the code:



If I execute the above code as a plain java application using java-mail jar, then I am getting output in proper html format as expected:

Test table format below

TEST_COLUMN_1 TEST_COLUMN_2 TEST_COLUMN_3

But if I execute the same code in a tomcat web container then the data isn't being displayed in HTML format but in weird format as mentioned below (see =09 symbols and special characters below). I double checked that in both cases the java mail 1.4.jar is invoked:

<!DOCTYPE html>
<html>
<head>
=09<style>
=09=09.bodyStyle {
=09=09=09font-family:'Calibri','sans-serif';
=09=09=09font-size:11.0pt;
=09=09}

=09=09.tableStyle {
=09=09=09font-family:'Calibri','sans-serif';
=09=09=09font-size:11.0pt;
=09=09=09border-spacing=3D:10;
=09=09}
=09=09
=09=09th, td{
=09=09=09padding: 10px;
=09=09}
=09</style>
</head>

<body class=3D"bodyStyle">

<table class=3D"tableStyle">
=09<tr>
        <th align=3D"left"><u>TEST_COLUMN_1</u></th> =09=09<th align=3D"left"><u>TEST_COLUMN_2</u></th> =09=09<th align=3D"left"><u>TEST_COLUMN_3</u></th>




Any help on this is greatly appreciated. I am guessing that this isn't definitely not an issue related with library or classpath but I am guessing something on the tomcat system setting vs plain java settings but not sure.

Thanks.
 
Jhonson Fernando
MyExamCloud Software Support
Ranch Hand
Posts: 692
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using default SMTP provider or any third party SMTP provider?
The issue might be related with class-path (You might have missed some jar files in WEB-INF/lib folder).
 
Rahul Chaitanya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is using Java Mail.jar that's in the classpath and I don't see any other mail related jar files in the lib.

But however, while debugging both the scenarios this is what I observed: "The provider settings are being set to javax.mail.provider [STORE, imap, ..etc] when I run it as a standalone app but when I run it in the tomcat those attributes are set to null". Please, see the screenshots below:

tomcat_no_providers.png
[Thumbnail for tomcat_no_providers.png]
No Providers are set in Tomcat
local_server_2.png
[Thumbnail for local_server_2.png]
Providers are set while running as standalone java app
 
Ron McLeod
Saloon Keeper
Posts: 1600
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the content has been quoted-printable encoded.  =09 represents a tab character, =3D represents an equals sign character.

Normally this isn't a problem because the client application which renders the content will recognise the encoding (by the presence of a Content-Transfer-Encoding: quoted-printable header or some other means) and decode it before presenting it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!