MailboxAddress from = MailboxAddress.parse(event.getFrom());
MailboxAddress recip = MailboxAddress.parse(event.getRecipient());
MimeMessage mm = parseInput(data);
Mailbox recipMailbox = resourceFactory.getMailbox(recip);
if (recipMailbox != null && !recipMailbox.isEmailDisabled()) {
log.debug("recipient is known to us, so store: " + recip);
storeMail(recipMailbox,mm);
} else {
Mailbox fromMailbox = resourceFactory.getMailbox(from);
if (fromMailbox != null && !fromMailbox.isEmailDisabled() ) {
log.debug("known from address, so will transmit: from: " + from);
mailSender.sendMail(mm);
} else {
throw new NullPointerException("Neither from address nor recipient are known to us. Will not store or send: from: " + event.getFrom() + " to: " + event.getRecipient());
}