/** * Returns <code>true</code> if the sender is anonymous, or * <code>false</code> if the email contains a sender. * @throws MessagingException */ public boolean isAnonymous() throws MessagingException { String sender = getOneFromAddress(); return sender==null || "Anonymous".equalsIgnoreCase(sender); }
@Override public String toString() { StringBuilder result = new StringBuilder("MsgId: ").append(getMessageID()); try { result = result.append("From: ").append(getOneFromAddress()); result = result.append("Recipients: "); for (Address recipient: getAllRecipients()) { if (result.length() > 1000) { result = result.append("..."); break; } if (result.length() > 0) result = result.append(", "); String recipientAddress = recipient.toString(); if (recipientAddress.length() > 20) result = result.append(recipientAddress).append("..."); else result = result.append(recipientAddress); } } catch (MessagingException e) { log.error("Error getting sender or recipients."); result.append("#Error#"); } return result.toString(); } }
/** * Returns the address replies to this email should be sent to. * If a <code>Reply-To</code> header exists, its value is returned. * Otherwise, if the recipient is a local identity (i.e. the email * was sent by somebody else), the sender is used; if the recipient * is not a local identity (sender was us), the recipient is used. * <br/> * Not to be confused with {@link #getReplyToAddresses()}. * @param identities * @throws MessagingException * @throws GeneralSecurityException * @throws IOException * @throws PasswordException */ public String getReplyAddress(Identities identities) throws MessagingException, PasswordException, IOException, GeneralSecurityException { Address[] replyTo = getReplyToAddresses(); if (replyTo!=null && replyTo.length>0) return replyTo[0].toString(); else { String sender = getOneFromAddress(); EmailIdentity senderIdentity = identities.extractIdentity(sender); if (senderIdentity != null) return getOneRecipient(); // sent by local user, so reply to recipient else return sender; // sent by other party, so reply to sender } }
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(); }
EmailDestination senderDestination = new EmailDestination(getOneFromAddress()); return cryptoImpl.verify(toByteArray(), signature, senderDestination.getPublicSigningKey()); } catch (Exception e) {
break; case FROM: value1 = displayFilter.getNameAndDestination(email1.getOneFromAddress()); value2 = displayFilter.getNameAndDestination(email2.getOneFromAddress()); break; case TO:
EmailIdentity senderIdentity = null; if (!email.isAnonymous()) { String sender = email.getOneFromAddress(); senderIdentity = identities.extractIdentity(sender); if (senderIdentity == null) {