Something wrong with the JavaMailTransport.send?

A

Abraham Khalil

Even if you close the transport connection object via the code below
It still has establish connections??

When you do Transport.send everytime, run the command netstat in
another shell and check all the open sockets incrementing every time
an email has been sent.

Is this a JavaMail bug?

=============================================================================

Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);

Authenticator pa = null; //default: no authentication

if (login != null && pwd != null) { //authentication required?
props.put("mail.smtp.auth", "true");

pa = new Authenticator () {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(login, pwd);
}
};
} // else: no authentication

Session session = Session.getInstance(props, pa);

Transport transport = null;
URLName urlName = new URLName("smtp://" + smtpServer + ":" + portNumber);

try {
transport = session.getTransport(urlName);
transport.connect();
transport.send(msg);
transport.close();
}
catch (Exception e) {
throw(e);
}
finally {
if (transport != null) transport.close();

System.err.println("Closing connection!!!!!!!!!!!!!!!");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top