Categories
Java

Java Email API

If you want to integrate email application in your java program or like me you want to reinvent wheel for curiosity, you can use Java mail API.

This API is available on Oracle website and free to download. So you can download it and add to your application to facilitate it with built in email.

This API is really simple to use and with few lines of coding you can send/receive email to/from different accounts.

For this purpose I have written a really simple application which sends an email from Windows live/hotmail account to another email address.

Here is the code :

All explanation is given inside of the code where it’s necessary. Otherwise, the code is pretty self-explanatory. The only comment to add is that every mail server has its own unique setting which is needed to be set at the setting part. Here for example I used Windows live/Hotmail setting and additionally I put Gmail account setting in comment part.

This API is very powerful and you also can attach file from the application or design application to notice user when an email arrives and so on.

I have plan to write about mentioned features in another post and the above code is just sample about how sending email is working in Java.

Exit mobile version