commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Baff (JIRA)" <>
Subject [jira] Created: (EMAIL-83) Problems using SMTP authentication with JavaMail 1.4.1
Date Tue, 28 Oct 2008 17:37:44 GMT
Problems using SMTP authentication with JavaMail 1.4.1

                 Key: EMAIL-83
             Project: Commons Email
          Issue Type: Bug
    Affects Versions: 1.1
         Environment: Java5, Netbeans 6.1, Commons/Email 1.1, JavaMail 1.4.1, JAF 1.1.1
            Reporter: Aaron Baff

I am trying to use SimpleEmail based off of the example on the Commons/Email site to send
an email. I plan on probably going to an HtmlEmail, but I thought I would start out simple
and basic. The code I am using is shown below. The problem I am running into is that my SMTP
server requires authentication, so I added the Authenticator as shown below with a correct
username and password (tested and known working). Unfortunately, my server keeps rejecting
my authentication so in javax.mail.Transport.send() @line 188 it tries to connected, fails
the authentication and then on the next line it tries to send the message which results in
an exception because the server won't let it send. I have found that in the javax.mail.Service.connect()
@line 206, it goes through the connect sequence which includes trying to find the user/pass
through various means. When it gets to line 268 it hasn't gotten a password yet, and so tries
to look it up on the session via javax.mail.Session.getPasswordAuthentication(). It uses the
Service.getURLName() as the key to pass to the authTable (HashTable) which contains PasswordAuthentication.
Unfortunately, the DefaultAuthenticator set as part of SimpleEmail.setAuthenticator() is in
the variable authenticator in the Session, not in the authTable. 

I have also tried with JavaMail 1.4 and similar results, although I did not run in debug and
step through it, I believe it performs the same behavior due to the 1.4.1 changes (
which say nothing about it.

SimpleEmail email = new SimpleEmail();
email.setAuthenticator(new DefaultAuthenticator("<USERNAME>", "<PASSWORD>"));
email.setHostName("<SMTP HOST>");
email.addTo("<TO EMAIL>", "Test Person");
email.setFrom("<FROM EMAIL>");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message