Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.mail.NoSuchProviderException: smtp failure

843834Dec 2 2009 — edited Dec 4 2009
I'm using latest mail.jar, latest activation.jar, jdk6.

My JavaMail util uses authorization credentials and works fine with my test mail server, but it fails with "javax.mail.NoSuchProviderException: smtp" when I try using my production mail server. The only difference is the connection url and credentials. The production mail server works fine when I use an external pop3 mail client to send/receive (i.e Outlook). The util that sends the mail is contained in a web app running under Tomcat.

I did see earlier topics on this subject but none ever gave a conclusive solution.

I sincerely appreciate any help! - the code follows.

Thanks,

--Bob
           Properties properties = System.getProperties();
           properties.put("mail.smtp.host", hostStr);

           properties.put("mail.smtp.auth", true);
           Authenticator auth = new PopupAuthenticator(userStr, passStr);
           Session session = Session.getInstance(properties, auth);
           session.setDebug(true);
           Transport tr = session.getTransport("smtp");
           tr.connect(hostStr, userStr, passStr);

           MimeMessage message = new MimeMessage(session);
           Address fromAddress = new InternetAddress(sndrAddr);
           message.setRecipients(Message.RecipientType.TO, toAddresses);
           message.setFrom(fromAddress);
           message.setSubject(msgSubj);
           message.setText(msgBody);

           Transport.send(message);

           ...

    static class PopupAuthenticator extends Authenticator {
        String username;
        String password;
        public PopupAuthenticator(String username,String password){
            this.username=username;
            this.password=password;
        }
        public PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username,password);
        }
    }
Edited by: rgc3679 on Dec 2, 2009 12:49 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2010
Added on Dec 2 2009
10 comments
3,200 views