try {
MimeMessage message = mail.getMessage();
// Invoke spamassian connection and scan the message
SpamAssassinInvoker sa = new SpamAssassinInvoker(spamdHost, spamdPort);
sa.scanMail(message);
// Add headers as attribute to mail object
for (String key : sa.getHeadersAsAttribute().keySet()) {
mail.setAttribute(key, sa.getHeadersAsAttribute().get(key));
}