commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Corey Scott (JIRA)" <>
Subject [jira] Commented: (EMAIL-83) Problems using SMTP authentication with JavaMail 1.4.1
Date Mon, 24 Nov 2008 06:29:44 GMT


Corey Scott commented on EMAIL-83:


I have tried to replicate this error and have yet been unable to do so.
(My environment is: Eclipse 3.4,  java 1.6.0_07, Email (trunk), Java Mail 1.4.1, Mail server:
James 2.3)

It however sounds like you know what the problem is, is it possible for you to point me in
the direction of the what you means by "uses the Service.getURLName() as the key to pass to
the authTable (HashTable)", so that I can look into a little more for you?


> Problems using SMTP authentication with JavaMail 1.4.1
> ------------------------------------------------------
>                 Key: EMAIL-83
>                 URL:
>             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.setDebug(true);
> email.setAuthenticator(new DefaultAuthenticator("<USERNAME>", "<PASSWORD>"));
> email.setHostName("<SMTP HOST>");
> email.setSmtpPort(587);
> email.addTo("<TO EMAIL>", "Test Person");
> email.setFrom("<FROM EMAIL>");
> email.setSubject("Test message");
> email.setMsg("This is a simple test of commons-email");
> email.send();

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

View raw message