transport.connect(host, port, username, password);
for (MimeMessage message : messages) {
// Attempt to send message, but catch exceptions caused by invalid
// addresses so that other messages can continue to be sent.
try {
transport.sendMessage(message,
message.getRecipients(MimeMessage.RecipientType.TO));
}
catch (AddressException ae) {
Log.error(ae.getMessage(), ae);
}