if (messageId != null) {
// preserve explicitly specified message id, as it may be lost on save
mimeMessage.setHeader("Message-ID", messageId);
}
LOG.debug("Sending MimMessage: {} using host: {}", mimeMessage, host);
transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
} finally {
try {
transport.close();
} catch (MessagingException e) {
LOG.warn("Error closing transport to host " + host + ". This exception will be ignored.", e);