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!!!!!!!!!!!!!!!");
}
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!!!!!!!!!!!!!!!");
}