Hi

I am having a problem getting James working with JavaMail and
authentication. I am running James 2.1.3 on XPPro and using Resin as my
servlet engine. I have a mail session defined in resin.conf as:

<resource jndi-name="mail/Session" type="javax.mail.Session">
    <init>
        <mail.transport.protocol>smtp</mail.transport.protocol>
        <mail.store.protocol>pop3</mail.store.protocol>
        <mail.host>localhost</mail.host>
        <mail.smtp.auth>true</mail.smtp.auth>
    </init>
</resource>

I then have a MailClient class defined as follows:

import com.dh.app.Application;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.naming.*;

public class MailClient extends Authenticator {

 private Context _ctx=null;
 private User _user=null;
 private Session _session=null;
 private PasswordAuthentication _authentication=null;

 public MailClient(User user) throws NamingException {
            _user=user;
            _authentication=new PasswordAuthentication(_user.getUsername(),
_user.getPassword());
            _ctx=new InitialContext();
            _session=(Session) _ctx.lookup(Application.getJNDISMTPPath());
 }

 public PasswordAuthentication getPasswordAuthentication() {
      return _authentication;
 }

 public void send(String from, String to, String subject, String content)
throws MessagingException {
             // Prepare mail message
             Message message=new MimeMessage(_session);
             message.setFrom(new InternetAddress(from));
             InternetAddress dests[]=new InternetAddress[] { new
InternetAddress(to) };
             message.setRecipients(Message.RecipientType.TO, dests);
             message.setSubject(subject);
             message.setContent(content, "text/plain");
             // Send mail message
             Transport.send(message);
 }

}

the User.getUsername() and User.getPassword() return the unencrypted text
for each of these values however when I try to send I get the following
exception:

javax.mail.SendFailedException: Sending failed;
  nested exception is:
        class javax.mail.AuthenticationFailedException


Any ideas what I am missing??

Thanks in advance!

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to