File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes Email from jBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Email from jBoss" Watch "Email from jBoss" New topic

Email from jBoss

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

First of all this is not for the book. This is a real query. I have seen a lot of posts which seems to be fabricated for winning the book. But this is a real problem.

I want to know how to send mails from jBoss. A google search revealed something which confused me. It said that mail sending is done through a bean java:/email or something. This confused me. I am using javax.mail.Transport to send the mail. The code is like this

Now it gives an exception when the connect method is called

javax.mail.MessagingException: Could not connect to SMTP host:, port: 25;
nested exception is: Software caused connection abort: connect

Now there are a few things I am not sure of. First of all I think the username and password given when calling connect method are those defined in the mail-service.xml in jBoss. Also is mailing on directly in jBoss or do I have to start it by configuring it.

I would be thankful to anyone who could help...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Does anyone has some idea :roll:
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

I don't have much experience with mail related configurations on JBoss. But the code that you posted doesn't look like JBoss specific. Are you following some tutorial or any other document where you got that from? And from what i remember, there was a chapter on mailing in some JBoss doc. Let me see if i can find it.

[My Blog] [JavaRanch Journal]
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Well after some research I have found that I can send email from my java application in two ways.

1. Use the OS SMPT service and send the mail which I am doing
2. Use jBoss to connect to a specific server to send the mail. For that you have to use the mail-service.xml file along with the jBoss email bean.

I am using the first one on Windows XP and the SMTP service on my windows XP is running. I used netstat -abno on command line to view all the ports which are listening but 25 port is not on the list. So I tried the second approach. But I got an exception as in the mail-service.xml file the emailing server was not configured. It was set to So is there any server which I can use to send my mail.

I am really stuck at this so really looking for some help :roll:
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169

actually i don't know the solution in JBossAS, but i think you use the email service that the AS provide as you use the DataSource instance, so
you can configure the parameters for your mail server that you use to send the email, and then get the JNDI context to mail session.

but as i told i don't know.

Best Regards.
I agree. Here's the link:
subject: Email from jBoss
It's not a secret anymore!