Best way to send an email using Java

Which email type should I send: Html or Plain text, why?
Well, html is nicer (and links are clickable, and font could be bolded etc) but may cause more problems because some email clients might not be able to read it, not to mention smartphones or other devices which might prefer plain text emails.

My suggestion is to send two emails, an html one and a plain text one - bundled together (multipart email) and let the email client decide which it wants to read.

But we still have some hurdles:
Not all email clients read CSS
Some firewalls might block html
Some firewalls might block images.

So what should I do? - I think the best option is to eliminate as much obstacles as necessary in the html version of the email, and then send it bundled with a plain text email which should cover all cases.

So lets by eliminating obstacles.
CSS can't be read by many email clients? - Don't use CSS in your emails.
HTML isn't supported? Bundle a plain text email with it.
Images don't get past firewalls? Don't put links to the images (which will then be recovered upon opening the email) but include the images with the email or even embed the images within the code using BASE64.
I will also use "alt" tags for the images so if the images aren't seen, at least the alternate text will be seen by the user.

How can I send html & plain text emails using one "send email" instance? - for that to happen we will send a multipart email which is an upgraded type of email which allows for "text" emails as well as for "html" emails, and then lets the email client decide which one to use.

Which Java library should I use?
After some searching I found that the most used libraries in java are Sun's own mail.jar (which might need also activation.jar) and apache's commons-email which uses Sun's library but simplifies the API.


Popular posts from this blog

Start Working with AutoIT

How to read Android apk contents

SCummVM for Android