Email email = new Email(outputStream.toByteArray()); email.setMessageID(packets[0].getMessageId()); // all packets in the array have the same message ID email.setSignatureFlag(); // incoming emails have no signature flag, so set it now; if it exists, don't trust but overwrite email.getMetadata().setReceivedDate(new Date()); inbox.add(email);
public void sendEmail(Email email) throws MessagingException, PasswordException, IOException, GeneralSecurityException { email.checkAddresses(); // sign email unless sender is anonymous if (!email.isAnonymous()) { String sender = email.getOneFromAddress(); EmailIdentity senderIdentity = identities.extractIdentity(sender); if (senderIdentity == null) throw new NoIdentityForSenderException(sender); email.sign(senderIdentity, identities); } email.setSignatureFlag(); // set the signature flag so the signature isn't reverified every time the email is loaded outbox.add(email); if (outboxProcessor != null) outboxProcessor.checkForEmail(); }