File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Error Sending mail using JavaMail. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Error Sending mail using JavaMail." Watch "Error Sending mail using JavaMail." New topic

Error Sending mail using JavaMail.

Hasif Subair

Joined: Aug 12, 2009
Posts: 24
I am learning to send an email from my java application. I am using jdk1.6, jboss AS 7.1.1 and I have downloaded the latest JavaMail api and JAF jars.
I have tried this tutorial from tutorialspoint

And I am getting this error.

I have no clue what this error is. Is there anything needs to configured? Do I need an smtp server? if so how integrate it with jboss. And also if you could suggest a good tutorial for the same.

Any help will be very much appreciated.

Greg Charles

Joined: Oct 01, 2001
Posts: 2967

Yes, the JavaMail API just interfaces with mail servers, it doesn't implement one. There are several free SMTP servers you could install for testing. You could also connect to your company's mail server, or if you have a gmail account, I believe you can connect to their SMTP server.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

There's also a fake SMTP server implementation called Dumbster that you can run to accept emails but not actually send them out. Useful for testing purposes. Otherwise, your ISP probably has a mail gateway that you can use.

Junilu - [How to Ask Questions] [How to Answer Questions]
Hasif Subair

Joined: Aug 12, 2009
Posts: 24
Thanks you both for your reply.

@Greg Charles
Can you give me a working code or tutorial for sending mail through gmail. I have tried a few from the net, but none is working.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10815

Moving to a more suitable forum

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
James Boswell

Joined: Nov 09, 2011
Posts: 1051

I second Junilu's suggestion. I've used Dumbster before, very useful for testing. It basically captures outgoing messages by listening on a particular port. You can even open the captured messages in your own email client (e.g. Outlook) to check their format and content. And on top of that, no emails are actually sent to the recipient but you can obviously see what the intended 'to' address is.
Hasif Subair

Joined: Aug 12, 2009
Posts: 24
I resolved this by using Apache James mail server. I am able to send mail through Gmail.
Hasif Subair

Joined: Aug 12, 2009
Posts: 24
For anyone looking having similar issues can try this tutorial here
I agree. Here's the link:
subject: Error Sending mail using JavaMail.
It's not a secret anymore!