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) { if (profile == null) {
profile = config.profile; 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 { try {
MimeMessage message = profile.toMimeMessage(email, session); MimeMessage message = profile.toMimeMessage(email, session);
@ -88,14 +88,12 @@ public class Account {
} }
transport.sendMessage(message, message.getAllRecipients()); transport.sendMessage(message, message.getAllRecipients());
} finally { } finally {
if (transport != null) {
try { try {
transport.close(); transport.close();
} catch (MessagingException me) { } catch (MessagingException me) {
logger.error("failed to close email transport for account [" + config.name + "]"); logger.error("failed to close email transport for account [" + config.name + "]");
} }
} }
}
return email; return email;
} }