Show a proper error when email password is not specified

Fixes elastic/elasticsearch#232

Original commit: elastic/x-pack-elasticsearch@2c0ab575d0
This commit is contained in:
uboness 2015-04-20 21:36:16 +02:00
parent f54c610c29
commit 175423b984
1 changed files with 5 additions and 7 deletions

View File

@ -75,7 +75,7 @@ public class Account {
if (profile == null) {
profile = config.profile;
}
transport.connect(config.smtp.host, config.smtp.port, user, new String(password));
transport.connect(config.smtp.host, config.smtp.port, user, password != null ? new String(password) : null);
try {
MimeMessage message = profile.toMimeMessage(email, session);
@ -88,14 +88,12 @@ public class Account {
}
transport.sendMessage(message, message.getAllRecipients());
} finally {
if (transport != null) {
try {
transport.close();
} catch (MessagingException me) {
logger.error("failed to close email transport for account [" + config.name + "]");
}
}
}
return email;
}