-
1. Re: How to configure a mail service in JBoss 7
ctomc Jul 19, 2012 5:41 AM (in response to ohmygod)Hi,
configuration of mail subsystem is done more structured way rather than just providing bunch of properties that system cannot understand and manage.
in any case i think this full blown example would help you out:
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:/Mail" from="user dot name at domain dot tld">
<smtp-server outbound-socket-binding-ref="mail-smtp" ssl="true">
<login name="nobody" password="pass"/>
</smtp-server>
<pop3-server outbound-socket-binding-ref="mail-pop3"/>
<imap-server outbound-socket-binding-ref="mail-imap">
<login name="nobody" password="pass"/>
</imap-server>
</mail-session>
<mail-session debug="true" jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
in general you have to specify what kind of server are you configuring and outbound-socket-binding-ref, this are defined globaly at the end of configuration (just look for mail-smtp in standalone-full.xml)
you can also set optional information about login info and/or server requres secure connection(ssl=true)
hope this helps
--
tomaz
-
2. Re: How to configure a mail service in JBoss 7
ohmygod Jul 19, 2012 5:57 AM (in response to ctomc)Thanks tomaz, I will have a try. Seems good
-
3. Re: How to configure a mail service in JBoss 7
ohmygod Jul 22, 2012 10:09 PM (in response to ohmygod)Hi tomaz, another question, how to configure an ssl protocal like, smtps? Or can you tell me all the optional attributes that can be configured?
-
4. Re: How to configure a mail service in JBoss 7
ctomc Jul 23, 2012 4:26 AM (in response to ohmygod)Hi,
simple just define smtp and specify ssl=true
<smtp-server outbound-socket-binding-ref="mail-smtp" ssl="true">
<login name="nobody" password="pass"/>
</smtp-server>
--
tomaz
-
5. Re: How to configure a mail service in JBoss 7
ohmygod Jul 23, 2012 11:17 PM (in response to ctomc)Hi Tomaz, can you also provide some code sample for the new mail service configuration in JBoss 7?
In older version JBoss, my code is like following. But I found in JBoss 7, using below code will report error like
10:33:56,019 ERROR [com.demo.util.mail.MailSender] (Thread-65 (HornetQ-client-global-threads-200946616)) Error getting email authentication parameters: com.demo.util.mail.MailerException: Mail -- service jboss.naming.context.java.Mail
After debugging, the real exception is
javax.naming.NameNotFoundException: Mail -- service jboss.naming.context.java.Mail
Code:
Context initCtx = new InitialContext(); javax.mail.Session session = (Session) initCtx.lookup("java:/Mail"); String transportProtocol = session.getProperty("mail.transport.protocol"); String mailServer = session.getProperty("mail.smtp.host"); String mailUser = session.getProperty("mail.smtp.user");
-
6. Re: How to configure a mail service in JBoss 7
ohmygod Jul 23, 2012 11:26 PM (in response to ohmygod)Changging the jndi name to "java:jboss/mail/Default" makes it work. Thanks again for the advice.