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);
// — Tạo đối tượng message