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

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

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

Mail.getRecipients介绍

[英]Returns the message recipients as a Collection of MailAddress objects, as specified by the SMTP "RCPT TO" command, or internally defined.
[中]按照SMTP“RCPT TO”命令的指定或内部定义,将邮件收件人作为邮件地址对象的集合返回。

代码示例

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

/**
 * @see org.apache.james.protocols.smtp.MailEnvelope#getRecipients()
 */
public List<MailAddress> getRecipients() {
  return new ArrayList<MailAddress>(mail.getRecipients());
}

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

@Override
  public void service(Mail mail) throws MessagingException {
    for (MailAddress recipient: mail.getRecipients()) {
      sieveExecutor.execute(recipient, mail);
    }
  }
}

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

public Collection<MailAddress> match(Mail mail) throws MessagingException {
    if (mail.getMessageSize() > cutoff) {
      return mail.getRecipients();
    } else {
      return null;
    }
  }
}

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

@Override
  public Collection<MailAddress> match(Mail mail) throws MessagingException {
    return mail.getRecipients();
  }
});

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

private RrtExecutionResult executeRrtFor(Mail mail) {
  Function<MailAddress, RrtExecutionResult> convertToMappingData = recipient -> {
    Preconditions.checkNotNull(recipient);
    return executeRrtForRecipient(mail, recipient);
  };
  return mail.getRecipients()
    .stream()
    .map(convertToMappingData)
    .reduce(RrtExecutionResult.empty(), RrtExecutionResult::merge);
}

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

public Collection<MailAddress> match(Mail mail) {
    if (senders.contains(mail.getSender())) {
      return mail.getRecipients();
    } else {
      return null;
    }
  }
}

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

public Collection<MailAddress> match(Mail mail) {
    String authUser = (String) mail.getAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME);
    if (authUser != null && users.contains(authUser)) {
      return mail.getRecipients();
    } else {
      return null;
    }
  }
}

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

@Override
public void service(Mail mail) {
  mail.getRecipients()
    .forEach(recipient -> filteringForRecipient(mail, recipient));
}

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

@Override
public void service(Mail mail) throws MessagingException {
  mail.getRecipients()
    .forEach(addStorageDirective(mail));
}

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

@Override
  public Collection<MailAddress> match(Mail mail) throws MessagingException {
    Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>());
    for (Matcher matcher : getMatchers()) {
      Collection<MailAddress> matcherResult = matcher.match(mail);
      if (matcherResult != null) {
        finalResult.removeAll(matcherResult);
      }
    }
    return finalResult;
  }
}

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

private boolean isValidForReply(final Mail mail, ActionVacation actionVacation, final ActionContext context) {
  Set<MailAddress> currentMailAddresses = ImmutableSet.copyOf(mail.getRecipients());
  Set<MailAddress> allowedMailAddresses = ImmutableSet.<MailAddress>builder().addAll(
    Lists.transform(actionVacation.getAddresses(), s -> retrieveAddressFromString(s, context)))
    .add(context.getRecipient())
    .build();
  return !Sets.intersection(currentMailAddresses, allowedMailAddresses).isEmpty();
}

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

@Override
public Collection<MailAddress> match(Mail mail) {
  Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail);
  if (firstMatchingRuleId.isPresent()) {
    DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get();
    setRuleIdAsMailAttribute(mail, ruleId);
    return mail.getRecipients();
  }
  return ImmutableList.of();
}

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

public Collection<MailAddress> match(Mail mail) {
    MailAddress mailAddress = mail.getSender();
    if (mailAddress == null) {
      return null;
    }
    String senderString = mailAddress.toString();
    if (pattern.matcher(senderString).matches()) {
      return mail.getRecipients();
    }
    return null;
  }
}

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

@Override
  public Collection<MailAddress> match(Mail mail) {
    if (! matchNetwork(mail.getRemoteAddr())) {
      return mail.getRecipients();
    }
    return null;
  }
}

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

private void serviceSingleServer(Mail mail, String originalName, Map.Entry<Domain, Collection<MailAddress>> entry) {
  if (configuration.isDebug()) {
    LOGGER.debug("Sending mail to {} on host {}", entry.getValue(), entry.getKey());
  }
  mail.setRecipients(entry.getValue());
  mail.setName(originalName + NAME_JUNCTION + entry.getKey().name());
  try {
    queue.enQueue(mail);
  } catch (MailQueueException e) {
    LOGGER.error("Unable to queue mail {} for recipients {}", mail.getName(), mail.getRecipients(), e);
  }
}

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

private void serviceNoGateway(Mail mail) {
  String mailName = mail.getName();
  Map<Domain, Collection<MailAddress>> targets = groupByServer(mail.getRecipients());
  for (Map.Entry<Domain, Collection<MailAddress>> entry : targets.entrySet()) {
    serviceSingleServer(mail, mailName, entry);
  }
}

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

public Collection<MailAddress> match(Mail mail) throws MessagingException {
    MimeMessage mm = mail.getMessage();
    String subject = mm.getSubject();
    if (subject != null && subject.startsWith(getCondition())) {
      return mail.getRecipients();
    }
    return null;
  }
}

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

public SMTPMessageSender sendMessage(Mail mail) throws MessagingException, IOException {
  String from = mail.getMaybeSender().asString();
  doHelo();
  doSetSender(from);
  mail.getRecipients().stream()
    .map(MailAddress::asString)
    .forEach(Throwing.consumer(this::doAddRcpt));
  doData(asString(mail.getMessage()));
  return this;
}

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

@Test
public void testInBlackList() throws MessagingException {
  Mail mail = createMail(LISTED_HOST.toString());
  setupMatcher(BLACKLIST);
  Collection<MailAddress> matchedRecipients = matcher.match(mail);
  assertThat(matchedRecipients).isNotNull();
  assertThat(matchedRecipients.size()).isEqualTo(mail.getRecipients().size());
}

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

public static MailProjection from(Mail mail) {
  return new MailProjection(mail.getName(), mail.getRecipients(),
    Iterators.toStream(mail.getAttributeNames())
      .map(name -> Pair.of(name, mail.getAttribute(name)))
      .collect(Guavate.toImmutableMap(Pair::getKey, Pair::getValue)));
}

相关文章