private boolean useDefault;
public Session create() {
final String password = properties.getProperty("password");
Authenticator auth = null;
if (password != null) {
final String protocol = properties.getProperty("mail.transport.protocol", "smtp");
String user = properties.getProperty("mail." + protocol + ".user");
if (user == null) {
user = properties.getProperty("mail.user");
}
if (user != null) {
final PasswordAuthentication pa = new PasswordAuthentication(user, password);
auth = new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return pa;
}
};
}