String mailHost = resourceBundle.getString("mailHost");
String authUser = resourceBundle.getString("authUser");
String authPassword = resourceBundle.getString("authPassword");
EmailAutherticator autherticator = new EmailAutherticator(authUser,authPassword);
Properties props = System.getProperties();
if (mailHost != null) {
props.put("mail.smtp.host", mailHost);
props.put("mail.smtp.auth", "true");
}
class EmailAutherticator extends Authenticator {
private String userName = null;
private String password = null;
public EmailAutherticator(String userName, String password) {
super();
this.userName = userName;
this.password = password;
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
}