Why is JavaMail not authenticated?

Today we learned that for our two clients JavaMail is not authenticated, so our product cannot send email. We have been sending emails through our own server for many years, as well as for several other clients, and we thought that we use authentication for all of these.

The code runs as follows:

    transport = session.getTransport("smtp");
    transport.connect(hostName, port, user, password);

According to the documentation here , JavaMail should use authentication if we used this form of the connect () method. We do not set any properties, but if I read this page correctly, we do not need to.

We use mail.jar from JBoss 4.2.1.GA.

What do we need to do differently?

Refresh . If I use a different method on this documentation page (by setting the mail.smtp.auth property and providing Authenticator), authentication will finally work. But what are we doing wrong with this method?

+3
source share
2 answers

I finally found that I'm calling:

transport.send(message, message.getAllRecipients());

which is a static method, not:

transport.sendMessage(message, message.getAllRecipients());

I think that’s why it wasn’t authenticated, so I think this is the real answer. It would help if I posted this part of the code, but I had no idea what the problem was. Life cannot find out for me why Transport.send () is a static method, but if you know, tell me .

+1
source

props.put("mail.debug", "true"); , .

, Windows, : http://forums.sun.com/thread.jspa?threadID=590866

+2

Source: https://habr.com/ru/post/1732072/


All Articles