javax.mail.internet.MimeMessage.getReplyTo()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(109)

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

MimeMessage.getReplyTo介绍

[英]Return the value of the RFC 822 "Reply-To" header field. If this header is unavailable or its value is absent, then the getFrom method is called and its value is returned. This implementation uses the getHeader method to obtain the requisite header field.
[中]返回RFC 822“回复”标题字段的值。如果此标头不可用或其值不存在,则调用getFrom方法并返回其值。此实现使用getHeader方法来获取必需的头字段。

代码示例

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testMessageFactorySetReplyTo() throws MessagingException {
  final MimeMessageBuilder builder = new MimeMessageBuilder(null);
  final String addresses = "testing1@example.com,testing2@example.com";
  assertNull(builder.build().getReplyTo());
  builder.setReplyTo(null);
  assertNull(builder.build().getReplyTo());
  builder.setReplyTo(addresses);
  assertArrayEquals(InternetAddress.parse(addresses), builder
      .build().getReplyTo());
}

代码示例来源:origin: spring-projects/spring-framework

assertEquals(1, froms.size());
assertEquals("me@mail.org", ((InternetAddress) froms.get(0)).getAddress());
List<Address> replyTos = Arrays.asList(sentMessage.getReplyTo());
assertEquals("reply@mail.org", ((InternetAddress) replyTos.get(0)).getAddress());
List<Address> tos = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.TO));

代码示例来源:origin: kiegroup/jbpm

assertEquals("'singleobject'", msg.getSubject());
assertEquals("from@domain.com", ((InternetAddress) msg.getFrom()[0]).getAddress());
assertEquals("replyTo@domain.com", ((InternetAddress) msg.getReplyTo()[0]).getAddress());

代码示例来源:origin: kiegroup/jbpm

assertEquals(mySubject, msg.getSubject());
assertEquals("from@domain.com", ((InternetAddress) msg.getFrom()[0]).getAddress());
assertEquals("replyTo@domain.com", ((InternetAddress) msg.getReplyTo()[0]).getAddress());

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * @return the 'replyTo' address of the email
 * @throws Exception parsing the mime message failed
 */
public String getReplyTo() throws Exception
{
  final javax.mail.Address[] addresses = this.mimeMessage.getReplyTo();
  if (addresses == null || addresses.length == 0)
  {
    return null;
  }
  return ((InternetAddress) addresses[0]).getAddress();
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * Get the ReplyTo addresses.
 */
@Override
public Address[] getReplyTo() throws MessagingException {
checkExpunged();
if (bodyLoaded)
  return super.getReplyTo();
loadEnvelope();
/*
 * The IMAP spec requires that the Reply-To field never be
 * null, but at least Exchange 2007 fails to fill it in in
 * some cases.  Use the same fallback strategy used by
 * MimeMessage.
 */
if (envelope.replyTo == null || envelope.replyTo.length == 0)
  return getFrom();
return aaclone(envelope.replyTo);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Get the ReplyTo addresses.
 */
public Address[] getReplyTo() throws MessagingException {
checkExpunged();
if (bodyLoaded)
  return super.getReplyTo();
loadEnvelope();
/*
 * The IMAP spec requires that the Reply-To field never be
 * null, but at least Exchange 2007 fails to fill it in in
 * some cases.  Use the same fallback strategy used by
 * MimeMessage.
 */
if (envelope.replyTo == null || envelope.replyTo.length == 0)
  return getFrom();
return aaclone(envelope.replyTo);
}

代码示例来源:origin: org.codemonkey.simplejavamail/simple-java-mail

/**
 * @return the 'replyTo' address of the email
 */
public InternetAddress getReplyTo() throws MessagingException {
  final Address[] addresses = this.mimeMessage.getReplyTo();
  if (addresses == null || addresses.length == 0) {
    return null;
  }
  return (InternetAddress) addresses[0];
}

代码示例来源:origin: TEAMMATES/teammates

@Test
public void testConvertToMimeMessage() throws Exception {
  EmailWrapper wrapper = getTypicalEmailWrapper();
  MimeMessage email = new JavamailService().parseToEmail(wrapper);
  assertEquals(new InternetAddress(wrapper.getSenderEmail(), wrapper.getSenderName()), email.getFrom()[0]);
  assertEquals(new InternetAddress(wrapper.getReplyTo()), email.getReplyTo()[0]);
  assertEquals(new InternetAddress(wrapper.getRecipient()), email.getRecipients(Message.RecipientType.TO)[0]);
  assertEquals(new InternetAddress(wrapper.getBcc()), email.getRecipients(Message.RecipientType.BCC)[0]);
  assertEquals(wrapper.getSubject(), email.getSubject());
  assertEquals(wrapper.getContent(), email.getContent().toString());
}

代码示例来源:origin: com.sun.mail/javax.mail

reply.setHeader("Subject", subject);
Address a[] = getReplyTo();
reply.setRecipients(Message.RecipientType.TO, a);
if (replyToAll) {

代码示例来源:origin: camunda/camunda-bpm-platform

reply.setHeader("Subject", subject);
Address a[] = getReplyTo();
reply.setRecipients(Message.RecipientType.TO, a);
if (replyToAll) {

代码示例来源:origin: miltonio/milton2

private MailboxAddress findReplyTo(MimeMessage mm) {
  try {
    return findSingleAddress(mm.getReplyTo());
  } catch (MessagingException ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: com.sun.mail/javax.mail

verifyAddresses(abort.getReplyTo());
} catch (final RuntimeException RE) {
  setErrorContent(abort, verify, RE);

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

/**
 * @see javax.mail.Message#getReplyTo()
 */
public Address[] getReplyTo() throws MessagingException {
  return getWrappedMessage().getReplyTo();
}

代码示例来源:origin: org.simplejavamail/simple-java-mail

@SuppressWarnings("WeakerAccess")
@Nullable
public static InternetAddress parseReplyToAddresses(@Nonnull final MimeMessage mimeMessage) {
  try {
    final Address[] addresses = mimeMessage.getReplyTo();
    return (addresses == null || addresses.length == 0) ? null : (InternetAddress) addresses[0];
  } catch (final MessagingException e) {
    throw new MimeMessageParseException(MimeMessageParseException.ERROR_PARSING_REPLY_TO_ADDRESSES, e);
  }
}

代码示例来源:origin: org.apache.commons/commons-email

/**
 * @return the 'replyTo' address of the email
 * @throws Exception parsing the mime message failed
 */
public String getReplyTo() throws Exception
{
  final javax.mail.Address[] addresses = this.mimeMessage.getReplyTo();
  if (addresses == null || addresses.length == 0)
  {
    return null;
  }
  return ((InternetAddress) addresses[0]).getAddress();
}

代码示例来源:origin: camunda/camunda-bpm-platform

verifyAddresses(abort.getReplyTo());
} catch (final RuntimeException RE) {
  setErrorContent(abort, verify, RE);

代码示例来源:origin: jenkinsci/acceptance-test-harness

/**
 * Does this email belong to our test case (as opposed to other tests that might be running elsewhere?)
 */
private boolean isOurs(MimeMessage m) {
  try {
    Address[] r = m.getReplyTo();
    if (r==null)    return false;
    for (Address a : r) {
      if (a.toString().contains(fingerprint))
        return true;
    }
    return false;
  } catch (MessagingException e) {
    throw new AssertionError(e);
  }
}

代码示例来源: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: com.sun.mail/android-mail

/**
 * Get the ReplyTo addresses.
 */
@Override
public Address[] getReplyTo() throws MessagingException {
checkExpunged();
if (bodyLoaded)
  return super.getReplyTo();
loadEnvelope();
/*
 * The IMAP spec requires that the Reply-To field never be
 * null, but at least Exchange 2007 fails to fill it in in
 * some cases.  Use the same fallback strategy used by
 * MimeMessage.
 */
if (envelope.replyTo == null || envelope.replyTo.length == 0)
  return getFrom();
return aaclone(envelope.replyTo);
}

相关文章

MimeMessage类方法