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

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

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

Mail.getMessage介绍

[英]Returns the MimeMessage stored in this message.
[中]返回存储在此消息中的mimessage。

代码示例

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

private boolean headerIsMailingList(Mail mail) throws MessagingException {
  return mail.getMessage()
    .getMatchingHeaders(MAILING_LIST_HEADERS)
    .hasMoreElements();
}

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

private boolean isMailingList(Mail mail) throws MessagingException {
    Enumeration<String> enumeration = mail.getMessage().getAllHeaderLines();
    while (enumeration.hasMoreElements()) {
      String headerName = enumeration.nextElement();
      if (headerName.startsWith("List-")) {
        return true;
      }
    }
    return false;
  }
}

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

/**
 * Returns the message.
 * 
 * @return MimeMessage
 */
protected MimeMessage getMessage() throws MessagingException {
  return getMail().getMessage();
}

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

@Override
  public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
    return new MimeMessageModifier(originalMail.getMessage());
  }
}

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

/**
 * Returns the message.
 * 
 * @return MimeMessage
 */
protected MimeMessage getMessage() throws MessagingException
{
  return getMail().getMessage();
}
/**

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

private Stream<String> getMessageSubjects(Mail mail) throws MessagingException {
  MimeMessage message = mail.getMessage();
  if (message != null) {
    return OptionalUtils.toStream(
      Optional.ofNullable(message.getSubject()));
  }
  return Stream.of();
}

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

private Stream<String> listFromHeaders(Mail mail) throws MessagingException {
  MimeMessage message = mail.getMessage();
  if (message != null) {
    return asStringStream(message.getFrom());
  }
  return Stream.of();
}

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

@Override
public boolean doTest(Mail mail) throws MessagingException, IOException {
  return Stream
    .concat(getMessageSubjects(mail), getMessageBodies(mail.getMessage()))
    .anyMatch(pattern.asPredicate());
}

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

@Override
public void process(Exchange arg0) throws Exception {
  Mail mail = arg0.getIn().getBody(Mail.class);
  LifecycleUtil.dispose(mail.getMessage());
  LifecycleUtil.dispose(mail);
  // stop routing
  arg0.setProperty(Exchange.ROUTE_STOP, true);
}

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

private Set<MailAddress> getReplyTosFromMail(Mail mail) {
  try {
    InternetAddress[] replyToArray = (InternetAddress[]) mail.getMessage().getReplyTo();
    if (replyToArray == null || replyToArray.length == 0) {
      return getSender(mail);
    }
    return getReplyTos(replyToArray);
  } catch (MessagingException ae) {
    LOGGER.warn("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
    return ImmutableSet.of();
  }
}

代码示例来源: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-mailets

private void createUnalteredMessage(Mail originalMail, MailImpl newMail) throws MessagingException {
  // if we need the original, create a copy of this message to
  // redirect
  if (mailet.getInitParameters().getPassThrough()) {
    newMail.setMessage(new CopiedMimeMessage(originalMail.getMessage()));
  }
  if (isDebug) {
    LOGGER.debug("Message resent unaltered.");
  }
}

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

public VacationReply build() throws MessagingException {
  Preconditions.checkState(eitherReasonOrMime());
  ActionUtils.detectAndHandleLocalLooping(originalMail, context, "vacation");
  MimeMessage reply = (MimeMessage) originalMail.getMessage().reply(false);
  reply.setSubject(generateNotificationSubject());
  reply.setContent(generateNotificationContent());
  return new VacationReply(retrieveOriginalSender(), ImmutableList.of(originalMail.getMaybeSender().get()), reply);
}

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

private List<MailAddress> customizeHeadersAndDeliver(Mail mail) throws MessagingException {
  MimeMessage message = mail.getMessage();
  // Set Return-Path and remove all other Return-Path headers from the message
  // This only works because there is a placeholder inserted by MimeMessageWrapper
  message.setHeader(RFC2822Headers.RETURN_PATH, mail.getMaybeSender().asPrettyString());
  List<MailAddress> errors = deliver(mail, message);
  return errors;
}

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

@Override
public void storeMail(MailAddress recipient, Mail mail) throws MessagingException {
  String username = computeUsername(recipient);
  String locatedFolder = locateFolder(username, mail);
  ComposedMessageId composedMessageId = mailboxAppender.append(mail.getMessage(), username, locatedFolder);
  metric.increment();
  LOGGER.info("Local delivered mail {} successfully from {} to {} in folder {} with composedMessageId {}", mail.getName(),
    mail.getMaybeSender().asString(), recipient.asPrettyString(), locatedFolder, composedMessageId);
}

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

@Test
public void vacationShouldNotSendNotificationToMailingLists() throws Exception {
  prepareTestUsingScript("org/apache/james/transport/mailets/delivery/vacationReason.script");
  Mail mail = createMail();
  mail.getMessage().addHeader("List-Id", "0123456789");
  testee.service(mail);
  assertThat(mail.getAttribute(MailStore.DELIVERY_PATH_PREFIX + LOCAL_PART)).isEqualTo(expressMailboxNameWithSlash(INBOX.getName()));
  assertThat(fakeMailContext.getSentMails()).isEmpty();
}

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

@Test
public void contentTypeOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
  Mail mail = FakeMail.builder()
    .mimeMessage(calendarMessage)
    .build();
  mailet.service(mail);
  Multipart multipart = (Multipart)mail.getMessage().getContent();
  int firstBodyPartIndex = 0;
  BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
  assertThat(firstBodyPart.getContentType()).isEqualTo("text/calendar; method=REPLY; charset=UTF-8");
}

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

private void writeToHeaders(Calendar calendar, Mail mail) throws MessagingException {
  MimeMessage mimeMessage = mail.getMessage();
  VEvent vevent = (VEvent) calendar.getComponent("VEVENT");
  addIfPresent(mimeMessage, X_MEETING_METHOD_HEADER, calendar.getMethod());
  addIfPresent(mimeMessage, X_MEETING_UID_HEADER, vevent.getUid());
  addIfPresent(mimeMessage, X_MEETING_RECURRENCE_ID_HEADER, vevent.getRecurrenceId());
  addIfPresent(mimeMessage, X_MEETING_SEQUENCE_HEADER, vevent.getSequence());
  addIfPresent(mimeMessage, X_MEETING_DTSTAMP_HEADER, vevent.getDateStamp());
}

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

@Test
public void contentTransferEncodingOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
  Mail mail = FakeMail.builder()
    .mimeMessage(calendarMessage)
    .build();
  mailet.service(mail);
  Multipart multipart = (Multipart)mail.getMessage().getContent();
  int firstBodyPartIndex = 0;
  BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
  assertThat(firstBodyPart.getHeader("Content-transfer-encoding")).containsExactly("8BIT");
}

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

@Test
public void contentClassOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
  Mail mail = FakeMail.builder()
    .mimeMessage(calendarMessage)
    .build();
  mailet.service(mail);
  Multipart multipart = (Multipart)mail.getMessage().getContent();
  int firstBodyPartIndex = 0;
  BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
  assertThat(firstBodyPart.getHeader("Content-class")).containsExactly("urn:content-classes:calendarmessage");
}

相关文章