[jboss-user] JBoss & Java Mail API: mail-service.xml configuration issue?

frusso at email.it frusso at email.it
Sat Feb 9 05:43:34 EST 2008

Hi everybody,
I'm a newbie in using JBoss and I'm trying to write a simple session  
bean that should provide kinda mail-delivery facility.

I've been googling for a couple of nights to finds docs explaining how  
to properly configure JBoss in order to be able to send mails by means  
of the Java Mail API, but I must confess I did not succeeded. I've  
only found out that it should be sufficient customizing the "mail- 
service.xml" file found under de deploy folder of (for example) the  
default folder. That's why I configured it in the following way:

--- my mail-service.xml ---
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z  
dimitris at jboss.org $ -->

==================================================================== -->
   <!-- Mail Connection  
==================================================================== -->

   <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
     <attribute name="JNDIName">java:/Mail</attribute>
     <attribute name="User">my at email.address</attribute>
     <attribute name="Password">my_passwd</attribute>
     <attribute name="Configuration">
       <!-- A test configuration -->
         <!-- Change to your mail server prototocol -->
         <property name="mail.store.protocol" value="pop3"/>
         <property name="mail.transport.protocol" value="smtp"/>

         <!-- Change to the mail server  -->
         <property name="mail.pop3.host" value="pop.somehost.it"/>

         <!-- Change to the SMTP gateway server -->
         <property name="mail.smtp.host" value="smtp.somehost.it"/>

         <!-- The mail server port -->
         <property name="mail.smtp.port" value="25"/>

         <!-- Change to the address mail will be from  -->
         <property name="mail.from" value="my at email.address"/>

         <!-- Enable debugging output from the javamail classes -->
         <property name="mail.debug" value="false"/>


My session bean looks like this:

--- MailerBean.java ---
public class MailerBean implements MailerLocal {

     private Session mail;

     public void sendMail(String email, String subject, String body)  
throws NamingException, MessagingException {
         InitialContext ctx = new InitialContext();
         mail = (Session) ctx.lookup("java:Mail");

         MimeMessage message = new MimeMessage(mail);
javax.mail.internet.InternetAddress.parse(email, false));

Well, at deploy time I obviously have no problems, but trying to run  
that service I get the following exception:

--- exception ---
javax.mail.SendFailedException: Invalid Addresses;
   nested exception is:
	com.sun.mail.smtp.SMTPAddressFailedException: 553 5.7.1 <my at email.address 
 >: Sender address rejected: not logged in


How's that? Am I missing some configuration element in the mail- 
session.xml file or should I do something more in my Java code?
Please, note that the email provider I'm trying to use for performing  
this very basic test is a public email provider that does not require  
neither SSL nor TLS, thus there should be plain password  
authentication I guess.

Hope this is not the wrong place for this post and thanks in advance  
to anyone who will want to help me,
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 Stanco di girare per trovare quello che ti piace? Su www.grandinettisport.com i migliori marchi dello sportwear
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7503&d=9-2

More information about the jboss-user mailing list