org.apache.mailet.Mail.hasSender()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.apache.mailet.Mail.hasSender()方法的一些代码示例,展示了Mail.hasSender()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mail.hasSender()方法的具体详情如下:
包路径:org.apache.mailet.Mail
类名称:Mail
方法名:hasSender

Mail.hasSender介绍

[英]Returns if this message has a sender. MaybeSender#nullSender() will be considered as no sender.
[中]如果此邮件有发件人,则返回。MaybeSender#nullSender()将被视为无发件人。

代码示例

代码示例来源:origin: org.apache.james/james-server-mailets

public Builder(Mail originalMail, ActionContext context) {
  Preconditions.checkArgument(originalMail.hasSender());
  this.originalMail = originalMail;
  this.context = context;
}

代码示例来源:origin: org.apache.james/james-server-mailets

private boolean hasSender(Mail originalMail) {
  if (!originalMail.hasSender()) {
    if (getInitParameters().isDebug()) {
      LOGGER.info("Processing a bounce request for a message with an empty reverse-path.  No bounce will be sent.");
    }
    return false;
  }
  return true;
}

代码示例来源:origin: org.apache.james/james-server-jmap

public VacationReply build(MimeMessageBodyGenerator mimeMessageBodyGenerator) throws MessagingException {
  Preconditions.checkState(mailRecipient != null, "Original recipient address should not be null");
  Preconditions.checkState(originalMail.hasSender(), "Original sender address should not be null");
  return new VacationReply(mailRecipient, OptionalUtils.toList(originalMail.getMaybeSender().asOptional()), generateMimeMessage(mimeMessageBodyGenerator));
}

代码示例来源:origin: org.apache.james/apache-mailet-base

@Override
public boolean isAutomaticallySent(Mail mail) throws MessagingException {
  return !mail.hasSender() ||
    isMailingList(mail) ||
    isAutoSubmitted(mail) ||
    isMdnSentAutomatically(mail);
}

代码示例来源:origin: org.apache.james/james-server-jmap

@Override
public void service(Mail mail) {
  try {
    if (!mail.hasSender()) {
      return;
    }
    if (! automaticallySentMailDetector.isAutomaticallySent(mail)) {
      ZonedDateTime processingDate = zonedDateTimeProvider.get();
      mail.getRecipients()
        .stream()
        .map(mailAddress -> manageVacation(mailAddress, mail, processingDate))
        .forEach(CompletableFuture::join);
    }
  } catch (Throwable e) {
    LOGGER.warn("Can not process vacation for one or more recipients in {}", mail.getRecipients(), e);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
  public Collection<MailAddress> match(Mail mail) {
    try {
      if (mail.hasSender()) {
        recipientRewriteTable.getMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain());
      }
    } catch (RecipientRewriteTable.TooManyMappingException e) {
      return mail.getRecipients();
    } catch (Exception e) {
      LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT");
    }
    return ImmutableList.of();
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

public void bounce(Mail mail, Exception ex) {
  if (!mail.hasSender()) {
    LOGGER.debug("Null Sender: no bounce will be generated for {}", mail.getName());
  } else {
    if (configuration.getBounceProcessor() != null) {
      mail.setAttribute(DELIVERY_ERROR, getErrorMsg(ex));
      try {
        mailetContext.sendMail(mail, configuration.getBounceProcessor());
      } catch (MessagingException e) {
        LOGGER.warn("Exception re-inserting failed mail: ", e);
      }
    } else {
      bounceWithMailetContext(mail, ex);
    }
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
public Collection<MailAddress> match(Mail mail) {
  if (!mail.hasSender()) {
    return null;

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
public void service(Mail originalMail) throws MessagingException {
  if (!originalMail.hasSender()) {
    passThrough(originalMail);
  } else {
    if (getInitParameters().isDebug()) {
      LOGGER.debug("Processing a bounce request for a message with a reverse path.  The bounce will be sent to {}", originalMail.getMaybeSender());
    }
    ProcessRedirectNotify.from(this).process(originalMail);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

private void doService(Mail mail) throws MessagingException {
  if (mail.hasSender()) {
    MailAddress sender = mail.getMaybeSender().get();
    String username = retrieveUser(sender);
    mailboxAppender.append(mail.getMessage(), username, folder);
    LOGGER.error("Local delivery with ToSenderFolder mailet for mail {} with sender {} in folder {}", mail.getName(), sender, folder);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

/**
 * Generates a bounce mail that is a bounce of the original message.
 *
 * @param bounceText the text to be prepended to the message to describe the bounce
 *                   condition
 * @return the bounce mail
 * @throws MessagingException if the bounce mail could not be created
 */
private MailImpl rawBounce(Mail mail, String bounceText) throws MessagingException {
  Preconditions.checkArgument(mail.hasSender(), "Mail should have a sender");
  // This sends a message to the james component that is a bounce of the sent message
  MimeMessage original = mail.getMessage();
  MimeMessage reply = (MimeMessage) original.reply(false);
  reply.setSubject("Re: " + original.getSubject());
  reply.setSentDate(new Date());
  Collection<MailAddress> recipients = mail.getMaybeSender().asList();
  MailAddress sender = mail.getMaybeSender().get();
  reply.setRecipient(Message.RecipientType.TO, new InternetAddress(mail.getMaybeSender().asString()));
  reply.setFrom(new InternetAddress(mail.getRecipients().iterator().next().toString()));
  reply.setText(bounceText);
  reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + mail.getName());
  return new MailImpl("replyTo-" + mail.getName(), sender, recipients, reply);
}

代码示例来源:origin: org.apache.james/james-server-mailets

if (!mail.hasSender()) {
  return;

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
protected boolean matchedWhitelist(MailAddress recipientMailAddress, Mail mail) throws MessagingException {
  if (!mail.hasSender()) {
    return true;

代码示例来源:origin: org.apache.james/apache-mailet-crypto

if (!mail.hasSender()) {
  return false;

代码示例来源:origin: org.apache.james/apache-mailet-crypto

if (!mail.hasSender()) {
  LOGGER.info("Can not sign: no sender");
  return false;

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
public Collection<MailAddress> match(Mail mail) throws MessagingException {
  // check if it's a local sender
  if (!mail.hasSender()) {
    return null;
  }
  MailAddress senderMailAddress = mail.getMaybeSender().get();
  if (getMailetContext().isLocalEmail(senderMailAddress)) {
    // is a local sender, so return
    return null;
  }
  String senderUser = senderMailAddress.getLocalPart();
  senderUser = senderUser.toLowerCase(Locale.US);
  Collection<MailAddress> recipients = mail.getRecipients();
  Collection<MailAddress> inWhiteList = new java.util.HashSet<>();
  for (MailAddress recipientMailAddress : recipients) {
    String recipientUser = recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
    Domain recipientHost = recipientMailAddress.getDomain();
    if (!getMailetContext().isLocalServer(recipientHost)) {
      // not a local recipient, so skip
      continue;
    }
    recipientUser = getPrimaryName(recipientUser);
    if (matchedWhitelist(recipientMailAddress, mail)) {
      // This address was already in the list
      inWhiteList.add(recipientMailAddress);
    }
  }
  return inWhiteList;
}

代码示例来源:origin: org.apache.james/james-server-mailets

private boolean senderDomainIsValid(Mail mail) throws MessagingException {
  return !mailet.getInitParameters().getFakeDomainCheck()
      || !mail.hasSender()
      || !mailet.getMailetContext()
    .getMailServers(mail.getMaybeSender().get()

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

if (!mail.hasSender()) {
  LOGGER.info("Mail to be bounced contains a null (<>) reverse path.  No bounce will be sent.");
  return;

代码示例来源:origin: org.apache.james/james-server-mailets

@Override
public void service(Mail mail) throws MessagingException {
  // Sanity checks
  if (!mail.hasSender()) {
    LOGGER.error("Sender is null");
    return;
  }
  if (!getMailetContext().isLocalServer(mail.getMaybeSender().get().getDomain())) {
    LOGGER.error("Sender not local");
    return;
  }
  // Update the Session for the current mail and execute
  SettableSession session = new SettableSession();
  if (mail.getAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME) != null) {
    session.setState(Session.State.AUTHENTICATED);
  } else {
    session.setState(Session.State.UNAUTHENTICATED);
  }
  session.setUser(mail.getMaybeSender().get().asString());
  getMailetContext().sendMail(
    mail.getRecipients().iterator().next(),
    mail.getMaybeSender().asList(),
    transcoder.execute(session, mail.getMessage()));
  mail.setState(Mail.GHOST);
  
  // And tidy up
  clearCaches();
}

相关文章