本文整理了Java中javax.mail.internet.MimeMessage.setReplyTo()
方法的一些代码示例,展示了MimeMessage.setReplyTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeMessage.setReplyTo()
方法的具体详情如下:
包路径:javax.mail.internet.MimeMessage
类名称:MimeMessage
方法名:setReplyTo
[英]Set the RFC 822 "Reply-To" header field. If the address parameter is null
, this header is removed.
[中]设置RFC 822“回复”标题字段。如果地址参数为null
,则删除此标头。
代码示例来源:origin: spring-projects/spring-framework
public void setReplyTo(InternetAddress replyTo) throws MessagingException {
Assert.notNull(replyTo, "Reply-to address must not be null");
validateAddress(replyTo);
this.mimeMessage.setReplyTo(new InternetAddress[] {replyTo});
}
代码示例来源:origin: stackoverflow.com
MimeMessage message = new MimeMessage(session);
message.setReplyTo(new javax.mail.Address[]
{
new javax.mail.internet.InternetAddress("mnop@gmail.com")
});
代码示例来源:origin: gocd/gocd
public MimeMessage createMessage(String from, String to, String subject, String body)
throws MessagingException {
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(TO, to);
msg.setSubject(subject);
msg.setContent(msg, "text/plain");
msg.setSentDate(new Date());
msg.setText(body);
msg.setSender(new InternetAddress(from));
msg.setReplyTo(new InternetAddress[]{new InternetAddress(from)});
return msg;
}
代码示例来源:origin: org.springframework/spring-context-support
public void setReplyTo(InternetAddress replyTo) throws MessagingException {
Assert.notNull(replyTo, "Reply-to address must not be null");
validateAddress(replyTo);
this.mimeMessage.setReplyTo(new InternetAddress[] {replyTo});
}
代码示例来源:origin: quartz-scheduler/quartz
protected MimeMessage prepareMimeMessage(MailInfo mailInfo)
throws MessagingException {
Session session = getMailSession(mailInfo);
MimeMessage mimeMessage = new MimeMessage(session);
Address[] toAddresses = InternetAddress.parse(mailInfo.getTo());
mimeMessage.setRecipients(Message.RecipientType.TO, toAddresses);
if (mailInfo.getCc() != null) {
Address[] ccAddresses = InternetAddress.parse(mailInfo.getCc());
mimeMessage.setRecipients(Message.RecipientType.CC, ccAddresses);
}
mimeMessage.setFrom(new InternetAddress(mailInfo.getFrom()));
if (mailInfo.getReplyTo() != null) {
mimeMessage.setReplyTo(new InternetAddress[]{new InternetAddress(mailInfo.getReplyTo())});
}
mimeMessage.setSubject(mailInfo.getSubject());
mimeMessage.setSentDate(new Date());
setMimeMessageContent(mimeMessage, mailInfo);
return mimeMessage;
}
代码示例来源:origin: oblac/jodd
/**
* Sets FROM, REPLY-TO and recipients.
*
* @param emailWithData {@link Email} with data
* @param msgToSet {@link MimeMessage} to set data into.
* @throws MessagingException if there is a failure
*/
private void setPeople(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
msgToSet.setFrom(emailWithData.from().toInternetAddress());
msgToSet.setReplyTo(EmailAddress.convert(emailWithData.replyTo()));
setRecipients(emailWithData, msgToSet);
}
代码示例来源:origin: loklak/loklak_server
message.addHeader("Content-Transfer-Encoding", "8bit");
message.setSentDate(new Date());
message.setReplyTo(new Address[]{new InternetAddress(senderEmail, displayname)});
message.setFrom(new InternetAddress(senderEmail, displayname));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(addressTo, false));
代码示例来源:origin: camunda/camunda-bpm-platform
this.message.setReplyTo(
this.toInternetAddressArray(this.replyList));
代码示例来源:origin: webx/citrus
message.setReplyTo(getAddresses(REPLY_TO));
代码示例来源:origin: webx/citrus
message.setReplyTo(getAddresses(REPLY_TO));
代码示例来源:origin: stackoverflow.com
Properties properties = new Properties();
props.put("mail.smtp.from", "abc@gmail.com");
Session session = Session.getDefaultInstance(props, null);
MimeMessage m = new MimeMessage(session);
m.addFrom(InternetAddress.parse("xyz@yahoo.com"));
m.setReplyTo(InternetAddress.parse("xyz@yahoo.com"));
代码示例来源:origin: biezhi/oh-my-email
public OhMyEmail replyTo(String replyTo) throws SendMailException {
try {
msg.setReplyTo(InternetAddress.parse(replyTo.replace(";", ",")));
} catch (Exception e) {
throw new SendMailException(e);
}
return this;
}
代码示例来源:origin: biezhi/oh-my-email
public OhMyEmail replyTo(String... replyTo) throws SendMailException {
String result = Arrays.asList(replyTo).toString().replaceAll("(^\\[|\\]$)", "").replace(", ", ",");
try {
msg.setReplyTo(InternetAddress.parse(result));
} catch (Exception e) {
throw new SendMailException(e);
}
return this;
}
代码示例来源:origin: org.apache.james/james-server-core-library
/**
* @see javax.mail.Message#setReplyTo(javax.mail.Address[])
*/
public void setReplyTo(Address[] addresses) throws MessagingException {
getWrappedMessageForWriting().setReplyTo(addresses);
}
代码示例来源:origin: stackoverflow.com
MimeMessage newMessage = new MimeMessage(session);
MimeMultipart mimeMultipart = new MimeMultipart();
MimeBodyPart attachment = new MimeBodyPart(is);
attachment.setHeader("Content-Type", "contentType");
mimeMultipart.addBodyPart(attachment);
newMessage.setContent(mimeMultipart);
newMessage.setFrom(InternetAddress.parse("fromAddress")[0]);
newMessage.setReplyTo(InternetAddress.parse("toAddress"));
newMessage.setSubject("subject");
代码示例来源:origin: org.dbflute.mail/mailflute
public void setReplyTo(List<Address> addressList) {
assertArgumentNotNull("addressList", addressList);
saveReplyTo(addressList);
try {
message.setReplyTo(addressList.toArray(new Address[addressList.size()]));
} catch (MessagingException e) {
String msg = buildAddressSettingFailureMessage("reply-to", addressList);
throw new SMailMessageSettingFailureException(msg, e);
}
}
代码示例来源:origin: org.jodd/jodd-mail
/**
* Sets FROM, REPLY-TO and recipients.
*
* @param emailWithData {@link Email} with data
* @param msgToSet {@link MimeMessage} to set data into.
* @throws MessagingException if there is a failure
*/
private void setPeople(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
msgToSet.setFrom(emailWithData.from().toInternetAddress());
msgToSet.setReplyTo(EmailAddress.convert(emailWithData.replyTo()));
setRecipients(emailWithData, msgToSet);
}
代码示例来源:origin: com.aliyun/aliyun-java-sdk-dm
private void setReplyto(Email email, MimeMessage message) throws UnsupportedEncodingException, MessagingException {
Address[] a = new Address[1];
a[0] = new InternetAddress(email.getReplyToAddress().getEmail(), email.getReplyToAddress().getName() == null ? "" : email.getReplyToAddress().getName());
message.setReplyTo(a);
}
private void setContent(Email email, MimeMessage message) throws UnsupportedEncodingException, MessagingException {
代码示例来源:origin: org.apache.james/james-server-mailets
@Test
public void replaceMailAddressesShouldReturnReplyToWhenAddressesMatchReplyTo() throws Exception {
MimeMessage message = MimeMessageUtil.defaultMimeMessage();
message.setReplyTo(InternetAddress.parse(MailAddressFixture.ANY_AT_JAMES.toString() + ", " + MailAddressFixture.OTHER_AT_JAMES.toString()));
FakeMail mail = FakeMail.from(message);
MailAddress expectedReplyTo = MailAddressFixture.ANY_AT_JAMES;
MailAddress expectedReplyTo2 = MailAddressFixture.OTHER_AT_JAMES;
Collection<MailAddress> addresses = testee.replaceSpecialAddresses(mail, ImmutableList.of(SpecialAddress.REPLY_TO));
assertThat(addresses).containsOnly(expectedReplyTo, expectedReplyTo2);
}
代码示例来源:origin: org.apache.james/james-server-mailets
@Test
public void replaceInternetAddressesShouldReturnReplyToWhenAddressesMatchReplyTo() throws Exception {
MimeMessage message = MimeMessageUtil.defaultMimeMessage();
message.setReplyTo(InternetAddress.parse(MailAddressFixture.ANY_AT_JAMES.toString() + ", " + MailAddressFixture.OTHER_AT_JAMES.toString()));
FakeMail mail = FakeMail.from(message);
MailAddress expectedReplyTo = MailAddressFixture.ANY_AT_JAMES;
MailAddress expectedReplyTo2 = MailAddressFixture.OTHER_AT_JAMES;
List<MailAddress> addresses = testee.replaceInternetAddresses(mail, ImmutableList.of(SpecialAddress.REPLY_TO.toInternetAddress()));
assertThat(addresses).containsOnly(expectedReplyTo, expectedReplyTo2);
}
内容来源于网络,如有侵权,请联系作者删除!