public Optional<MailAddress> getReplyTo(Mail originalMail) { if (replyTo.isPresent()) { if (replyTo.get().equals(SpecialAddress.UNALTERED)) { return Optional.empty(); } return originalMail.getMaybeSender().asOptional(); } return Optional.empty(); } }
public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(mailAddress -> !mailAddress.equals(context.getRecipient())) .collect(Guavate.toImmutableList())); } }
/** * Sets the "reverse-path" of <i>newMail</i> to <i>reversePath</i>. If the * requested value is <code>SpecialAddress.NULL</code> sets it to "<>". If * the requested value is null does nothing. */ public void setReversePath(Optional<MailAddress> maybeReversePath) { if (maybeReversePath.isPresent()) { MailAddress reversePath = maybeReversePath.get(); if (reversePath.equals(SpecialAddress.NULL)) { mail.setSender(null); if (mailet.getInitParameters().isDebug()) { LOGGER.debug("reversePath set to: null"); } } else { mail.setSender(reversePath); if (mailet.getInitParameters().isDebug()) { LOGGER.debug("reversePath set to: {}", reversePath); } } } }
if (recipients.size() == 1 && whitelistManagerAddress != null && whitelistManagerAddress.equals(recipients.toArray()[0])) {
/** * <p> * Sets the "Reply-To:" header of <i>newMail</i> to <i>replyTo</i>. * </p> * If the requested value is <code>SpecialAddress.NULL</code> will remove * the "Reply-To:" header. If the requested value is null does nothing.</p> */ public void setReplyTo(Optional<MailAddress> optionalReplyTo) throws MessagingException { if (optionalReplyTo.isPresent()) { MailAddress replyTo = optionalReplyTo.get(); if (replyTo.isNullSender() || replyTo.equals(SpecialAddress.NULL)) { mail.getMessage().setReplyTo(null); if (mailet.getInitParameters().isDebug()) { LOGGER.debug("replyTo set to: null"); } } else { mail.getMessage().setReplyTo(new InternetAddress[] { replyTo.toInternetAddress() }); if (mailet.getInitParameters().isDebug()) { LOGGER.debug("replyTo set to: {}", replyTo); } } } }
continue; if (mailAddress.equals(reversePath)) { return true;
/** * Detect and handle locally looping mail. External loop detection is left * to the MTA. * * @param aMail * @param context not null * @param anAttributeSuffix * @throws MessagingException */ public static void detectAndHandleLocalLooping(Mail aMail, ActionContext context, String anAttributeSuffix) throws MessagingException { MailAddress thisRecipient = getSoleRecipient(aMail); MailAddress lastRecipient = (MailAddress) aMail .getAttribute(ATTRIBUTE_PREFIX + anAttributeSuffix); if (null != lastRecipient && lastRecipient.equals(thisRecipient)) { MessagingException ex = new MessagingException( "This message is looping! Message ID: " + aMail.getMessage().getMessageID()); LOGGER.warn(ex.getMessage(), ex); throw ex; } aMail.setAttribute(ATTRIBUTE_PREFIX + anAttributeSuffix, thisRecipient); } }