本文整理匯總了Java中org.springframework.mail.SimpleMailMessage.setReplyTo方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleMailMessage.setReplyTo方法的具體用法?Java SimpleMailMessage.setReplyTo怎麽用?Java SimpleMailMessage.setReplyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.mail.SimpleMailMessage
的用法示例。
在下文中一共展示了SimpleMailMessage.setReplyTo方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendMailAsBcc
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* 指定された宛先一覧に BCC で一括送信します。
*
* @param recipients 宛先一覧
* @param subject 件名
* @param text 本文
*/
@Async
public void sendMailAsBcc(List<String> recipients, String subject, String text) {
if (recipients.isEmpty()) {
throw new IllegalArgumentException("recipients is empty.");
}
SimpleMailMessage message = new SimpleMailMessage();
message.setReplyTo(appReply);
message.setBcc(recipients.toArray(new String[recipients.size()]));
message.setSubject(subject);
message.setText(text);
try {
mailSender.send(message);
} catch (MailException e) {
exceptionHandler.accept(e);
}
}
示例2: sendAttendMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* 登録完了メールを送信します。
*
* @param membership メンバー情報
* @param convocation 対象のイベント招待
*/
@Async
void sendAttendMail(Membership membership, Convocation convocation) {
SimpleMailMessage message = new SimpleMailMessage();
message.setReplyTo(appReply);
message.setBcc(appReply);
message.setTo(membership.getEmail());
message.setSubject("【登録完了】" + convocation.getSubject());
message.setText(membership.getName() + " さん\n\n" +
convocation.getSubject() + "の登録が完了しました。\n\n" +
"詳細の確認・登録內容の変更は以下 URL より行ってください。\n" +
appUrl + "\n\n" +
"本メールに関するお問合せ先: " + appReply + "\n" +
"Java研修 Go研修 OB・OG會");
try {
mailSender.send(message);
} catch (MailException e) {
exceptionHandler.accept(e);
}
}
示例3: sendCancelMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* キャンセル完了メールを送信します。
*
* @param membership メンバー情報
* @param convocation 対象のイベント招待
*/
@Async
void sendCancelMail(Membership membership, Convocation convocation) {
SimpleMailMessage message = new SimpleMailMessage();
message.setReplyTo(appReply);
message.setBcc(appReply);
message.setTo(membership.getEmail());
message.setSubject("【キャンセル完了】" + convocation.getSubject());
message.setText(membership.getName() + " さん\n\n" +
convocation.getSubject() + "の登録キャンセルが完了しました。\n\n" +
"詳細の確認・登録內容の変更は以下 URL より行ってください。\n" +
appUrl + "\n\n" +
"本メールに関するお問合せ先: " + appReply + "\n" +
"Java研修 Go研修 OB・OG會");
try {
mailSender.send(message);
} catch (MailException e) {
exceptionHandler.accept(e);
}
}
示例4: sendPasswordResetMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* パスワードリセット案內メールを送信します。
*
* @param request パスワードリセット要求
*/
@Async
void sendPasswordResetMail(PasswordResetRequest request) {
SimpleMailMessage message = new SimpleMailMessage();
message.setReplyTo(appReply);
message.setTo(request.getMembership().getEmail());
message.setSubject("【パスワードリセット】Java研修 Go研修 OB・OG會");
message.setText(request.getMembership().getName() + " さん\n\n" +
"パスワードリセットの要求を受け付けました。\n" +
"下記 URL から 24 時間以內にパスワードリセットを行ってください。\n\n" +
appUrl + "/#!" + ResetPasswordView.VIEW_NAME + "/" + request.getToken() + "\n" +
"※トップページにリダイレクトされてしまう場合は、トップページを開いた畫麵 (タブ) のアドレス欄に" +
"上記 URL を張り付けて移動してください。\n\n" +
"本メールに関するお問合せ先: " + appReply + "\n" +
"Java研修 Go研修 OB・OG會");
try {
mailSender.send(message);
} catch (MailException e) {
exceptionHandler.accept(e);
}
}
示例5: sendUpdateMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* メンバー情報更新完了メールを送信します。
*
* @param membership メンバー情報
*/
@Async
void sendUpdateMail(Membership membership) {
SimpleMailMessage message = new SimpleMailMessage();
message.setReplyTo(appReply);
message.setBcc(appReply);
message.setTo(membership.getEmail());
message.setSubject("【會員情報編集完了】Java研修 Go研修 OB・OG會");
message.setText(membership.getName() + " さん\n\n" +
"會員情報の編集が完了しました。\n\n" +
"詳細の確認・登録內容の変更は以下 URL より行ってください。\n" +
appUrl + "\n\n" +
"本メールに関するお問合せ先: " + appReply + "\n" +
"Java研修 Go研修 OB・OG會");
try {
mailSender.send(message);
} catch (MailException e) {
exceptionHandler.accept(e);
}
}
示例6: send
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Override
public void send(MailMessage message) throws MailSenderException {
SimpleMailMessage smm = new SimpleMailMessage();
MailBody body = message.getBody();
smm.setText(MailUtils.toPlainText(body));
MailHead head = message.getHead();
smm.setFrom(head.getFrom());
smm.setReplyTo(head.getReplyTo());
smm.setSubject(head.getSubject());
smm.setTo(asArray(head.getTo()));
smm.setCc(asArray(head.getCc()));
smm.setBcc(asArray(head.getBcc()));
smm.setSentDate(head.getSentDate());
LOG.info("message to send {}", smm);
mailSender.send(smm);
}
示例7: sendMessage
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
private void sendMessage(String subject, String message)
{
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(ObserverProperties.getMailReceiver());
mailMessage.setReplyTo(ObserverProperties.getMailReplyTo());
mailMessage.setFrom(ObserverProperties.getMailSender());
mailMessage.setSubject(subject);
mailMessage.setText(message);
mailSender.send(mailMessage);
}
示例8: sendTextMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Override
public void sendTextMail(final MailMetaData mailMetaData, final String text) {
if (suppressMail) {
return;
}
final SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(new StringBuilder().append(mailMetaData.getFromName()).append(" <").append(mailMetaData.getFromAddress())
.append(">").toString());
mailMessage.setSubject(mailMetaData.getSubject());
mailMessage.setReplyTo(mailMetaData.getReplyTo());
if (mailMetaData.getCcAddresses() != null && mailMetaData.getCcAddresses().size() > 0) {
mailMessage.setCc((String[]) mailMetaData.getCcAddresses().toArray(new String[mailMetaData.getCcAddresses().size()]));
}
if (mailMetaData.getBccAddresses() != null && mailMetaData.getBccAddresses().size() > 0) {
mailMessage.setBcc((String[]) mailMetaData.getBccAddresses().toArray(new String[mailMetaData.getBccAddresses().size()]));
}
if (mailMetaData.getToAddresses() != null && mailMetaData.getToAddresses().size() > 0) {
mailMessage.setTo((String[]) mailMetaData.getToAddresses().toArray(new String[mailMetaData.getToAddresses().size()]));
}
mailMessage.setText(text);
try {
mailSender.send(mailMessage);
} catch (MailException e) {
throw new SendMailException(new StringBuilder().append("Error sending mail: ").append(mailMetaData.toString()).toString(),
e);
}
}
示例9: sendTextMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* API to send mail using javaMailSender.
*
* @param mailMetaData
* @param text
* @throws WizardMailException
*/
private void sendTextMail(final MailMetaData mailMetaData, final String text) throws WizardMailException {
LOGGER.info("Entering method sendTextMail....");
final SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(new StringBuilder().append(mailMetaData.getFromName()).append(MailConstants.SPACE).append(
MailConstants.LESS_SYMBOL).append(mailMetaData.getFromAddress()).append(MailConstants.GREATER_SYMBOL).toString());
mailMessage.setSubject(mailMetaData.getSubject());
mailMessage.setReplyTo(mailMetaData.getReplyTo());
if (mailMetaData.getCcAddresses() != null && mailMetaData.getCcAddresses().size() > 0) {
mailMessage.setCc((String[]) mailMetaData.getCcAddresses().toArray(new String[mailMetaData.getCcAddresses().size()]));
}
if (mailMetaData.getBccAddresses() != null && mailMetaData.getBccAddresses().size() > 0) {
mailMessage.setBcc((String[]) mailMetaData.getBccAddresses().toArray(new String[mailMetaData.getBccAddresses().size()]));
}
if (mailMetaData.getToAddresses() != null && mailMetaData.getToAddresses().size() > 0) {
mailMessage.setTo((String[]) mailMetaData.getToAddresses().toArray(new String[mailMetaData.getToAddresses().size()]));
}
mailMessage.setText(text);
try {
LOGGER.info("Sending mail using JavaMailSender....");
wizardMailSender.send(mailMessage);
} catch (MailException e) {
LOGGER.error("Exception occured during sending Email.Email meta deta is " + mailMetaData.toString() + ".Excption is "
+ e.getMessage(), e);
throw new WizardMailException(new StringBuilder().append("Error sending mail: ").append(mailMetaData.toString())
.toString(), e);
}
LOGGER.info("Mail sent successfully.Exiting method sendTextMail....");
}
示例10: sendEmail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
public void sendEmail(String subject,
String emailBody,
String to,
String bcc,
String from,
String replyTo,
String host){
SimpleMailMessage mailMessage = new SimpleMailMessage();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);
if(StringUtils.isNotBlank(to)){
mailMessage.setTo(to);
}
if(StringUtils.isNotBlank(bcc)){
mailMessage.setBcc(bcc);
}
if(StringUtils.isNotBlank(from)){
mailMessage.setFrom(from);
}
if(StringUtils.isNotBlank(replyTo)){
mailMessage.setReplyTo(replyTo);
}
if(StringUtils.isNotBlank(subject)){
mailMessage.setSubject(subject);
}
mailMessage.setText(emailBody);
mailSender.send(mailMessage);
logger.info("Email Message has been sent..");
}
示例11: javaMailSenderWithSimpleMessage
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Test
public void javaMailSenderWithSimpleMessage() throws MessagingException, IOException {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("host");
sender.setPort(30);
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage = new SimpleMailMessage();
simpleMessage.setFrom("[email protected]");
simpleMessage.setReplyTo("[email protected]");
simpleMessage.setTo("[email protected]");
simpleMessage.setCc(new String[] {"[email protected]", "[email protected]"});
simpleMessage.setBcc(new String[] {"[email protected]", "[email protected]"});
Date sentDate = new GregorianCalendar(2004, 1, 1).getTime();
simpleMessage.setSentDate(sentDate);
simpleMessage.setSubject("my subject");
simpleMessage.setText("my text");
sender.send(simpleMessage);
assertEquals("host", sender.transport.getConnectedHost());
assertEquals(30, sender.transport.getConnectedPort());
assertEquals("username", sender.transport.getConnectedUsername());
assertEquals("password", sender.transport.getConnectedPassword());
assertTrue(sender.transport.isCloseCalled());
assertEquals(1, sender.transport.getSentMessages().size());
MimeMessage sentMessage = sender.transport.getSentMessage(0);
List<Address> froms = Arrays.asList(sentMessage.getFrom());
assertEquals(1, froms.size());
assertEquals("[email protected]", ((InternetAddress) froms.get(0)).getAddress());
List<Address> replyTos = Arrays.asList(sentMessage.getReplyTo());
assertEquals("[email protected]", ((InternetAddress) replyTos.get(0)).getAddress());
List<Address> tos = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.TO));
assertEquals(1, tos.size());
assertEquals("[email protected]", ((InternetAddress) tos.get(0)).getAddress());
List<Address> ccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.CC));
assertEquals(2, ccs.size());
assertEquals("[email protected]", ((InternetAddress) ccs.get(0)).getAddress());
assertEquals("[email protected]", ((InternetAddress) ccs.get(1)).getAddress());
List<Address> bccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.BCC));
assertEquals(2, bccs.size());
assertEquals("[email protected]", ((InternetAddress) bccs.get(0)).getAddress());
assertEquals("[email protected]", ((InternetAddress) bccs.get(1)).getAddress());
assertEquals(sentDate.getTime(), sentMessage.getSentDate().getTime());
assertEquals("my subject", sentMessage.getSubject());
assertEquals("my text", sentMessage.getContent());
}
示例12: enviar
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@RequestMapping(method = POST)
@ResponseStatus(HttpStatus.CREATED)
public void enviar() {
for (Usuario usuario : usuarios.todos()) {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(usuario.getEmail());
mailMessage.setReplyTo("[email protected]");
mailMessage.setFrom("[email protected]");
String nomeAmigo = usuario.getAmigoSecreto().getNome();
mailMessage.setSubject( "Seu amigo secreto é " + nomeAmigo );
mailMessage.setText( "É com imenso prazer que informamos que o seu amigo(a) secreto é o (a): " + nomeAmigo + ""
+ ". Lembre de dar um presente bem bacana para ele(a)." );
javaMailSender.send(mailMessage);
}
}
示例13: sendSecureEmail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
public void sendSecureEmail(String subject,
String emailBody,
String to,
String bcc,
String from,
String replyTo,
String host,
String password){
SimpleMailMessage mailMessage = new SimpleMailMessage();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);
mailSender.setPort(587);
mailSender.setProtocol("smtp");
Properties props = new Properties();
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
mailSender.setJavaMailProperties(props);
if(StringUtils.isNotBlank(to)){
mailMessage.setTo(to);
}
if(StringUtils.isNotBlank(bcc)){
mailMessage.setBcc(bcc);
}
if(StringUtils.isNotBlank(from)){
mailMessage.setFrom(from);
mailSender.setUsername(from);
}
if(StringUtils.isNotBlank(password)){
mailSender.setPassword(password);
}
if(StringUtils.isNotBlank(replyTo)){
mailMessage.setReplyTo(replyTo);
}
if(StringUtils.isNotBlank(subject)){
mailMessage.setSubject(subject);
}
mailMessage.setText(emailBody);
mailSender.send(mailMessage);
logger.info("Secure Email Message has been sent..");
}