本文整理匯總了Java中org.springframework.mail.SimpleMailMessage.setSubject方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleMailMessage.setSubject方法的具體用法?Java SimpleMailMessage.setSubject怎麽用?Java SimpleMailMessage.setSubject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.mail.SimpleMailMessage
的用法示例。
在下文中一共展示了SimpleMailMessage.setSubject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Override
@Async
// 異步發送郵件
public void sendMail(Comment comment, Article article) {
if (properties.getNotification()) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(properties.getFrom());
message.setTo(properties.getTo());
message.setSubject(properties.getSubject());
String messageText = properties.getText()
.replace("author", comment.getAuthor())
.replace("title", article.getTitle())
.replace("text", comment.getText())
.replace("agent", comment.getAgent())
.replace("ip", Optional.ofNullable(comment.getIp()).orElse(""));
message.setText(messageText);
mailSender.send(message);
}
}
示例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: 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);
}
}
示例4: sendSimpleMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* 發送文本郵件
* @param to
* @param subject
* @param content
*/
@Override
public void sendSimpleMail(String to, String subject, String content) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(content);
try{
mailSender.send(message);
logger.info("郵件已經發送!");
}catch (Exception e){
logger.error("發送郵件發生異常!",e);
}
}
示例5: confirmRegistration
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
private void confirmRegistration(OnRegistrationCompleteEvent event) {
User user = event.getUser();
String token = UUID.randomUUID().toString();
userService.createVerificationToken(user, token);
String recipientAddress = user.getEmail();
String subject = "AntiSocial Registration Confirmation";
String confirmationUrl = event.getAppUrl() + "/registrationConfirm?token=" + token;
String message = "Hi "+user.getName()+" ,\n\nPlease confirm your e-mail with this link. ";
SimpleMailMessage email = new SimpleMailMessage();
email.setTo(recipientAddress);
email.setSubject(subject);
email.setText(message + "\n\n" + confirmationUrl + "\n\n\nw/ AntiSocial Team");
mailSender.send(email);
}
示例6: sendAlarm
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
public void sendAlarm(AlarmMessage data) {
SimpleMailMessage mail = new SimpleMailMessage(); // 隻發送純文本
mail.setText(data.getMessage());// 郵件內容
mail.setSubject(TITLE);// 主題
mail.setFrom(emailUsername);
String receiveKeys[] = StringUtils.split(StringUtils.replace(data.getReceiveKey(), ";", ","), ",");
List<String> address = new ArrayList<String>();
for (String receiveKey : receiveKeys) {
if (isEmailAddress(receiveKey)) {
address.add(receiveKey);
} else if (isMobileNumber(receiveKey)) {
// do nothing
}
}
if (address != null && !address.isEmpty()) {
mail.setTo(address.toArray(new String[address.size()]));
sendMail(mail);
}
}
示例7: 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);
}
示例8: sendEmailToNewEmailOnChange
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/**
* Email new address only - called if email address had not previously been set.
*
* @param certDn DN of the certificate that is being updated
* @param requesterDn DN of the user making the change request
* @param newEmail New email address
* @param cert_key PK of cert being updated
*/
public void sendEmailToNewEmailOnChange(String certDn, String requesterDn,
String newEmail, long cert_key) {
log.debug("sendEmailToNewEmailOnChange method");
StringBuilder emailDebug = new StringBuilder("Emailing new email address [");
emailDebug.append(newEmail);
// Create a thread safe "copy" of the template message and customize it
SimpleMailMessage msg = new SimpleMailMessage(this.emailTemplate);
msg.setTo(newEmail);
msg.setSubject("UK CA Email Updated");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("cert_dn", certDn);
vars.put("requester_dn", requesterDn);
vars.put("basePortalUrl", basePortalUrl);
vars.put("req_key", cert_key);
vars.put("new_email", newEmail);
try {
this.mailSender.send(msg, vars, this.emailRaNewEmailChangeTemplate);
} catch (MailException ex) {
log.error("MailSender " + ex.getMessage());
}
emailDebug.append("]");
log.debug(emailDebug);
}
示例9: dispatch
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Override
public void dispatch(String messageSubject, String messageContent, String to)
throws Exception {
// Simple checks for acceptability
if (!to.matches("[email protected]+")) {
log.info("did not send email notification: improper email address \""
+ to + "\"");
return;
}
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to.trim());
message.setSubject(messageSubject);
message.setText(messageContent);
sender.send(message);
}
示例10: sendEmailMsg
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
private void sendEmailMsg(String email, String content) {
logger.info("kaishi");
JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
// 設定mail server
senderImpl.setHost(mailHost);
senderImpl.setUsername(mailUserName);
senderImpl.setPassword(mailPassword);
Properties prop = new Properties();
// 將這個參數設為true,讓服務器進行認證,認證用戶名和密碼是否正確
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.timeout", "25000");// milliseconds
senderImpl.setJavaMailProperties(prop);
// 建立郵件消息
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(email);
mailMessage.setFrom(mailSender);
mailMessage.setSubject("sam驗證碼");
mailMessage.setText(content);
// 發送郵件
senderImpl.send(mailMessage);
logger.info("successfully send mail");
}
示例11: publish
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@Override
public void publish(final Event event) throws PublishException {
try {
final VelocityContext context = velocityRenderer.getContext(event);
final SimpleMailMessage email = new SimpleMailMessage();
email.setFrom(getFrom());
email.setSubject(velocityRenderer.render(getSubject(), context));
email.setText(velocityRenderer.render(getTextMessage(), context) + " ");
final String to2 = getTo();
email.setTo(to2.split(",|\\s"));
mailSender.send(email);
logger.info("Sent event notification to: {}", to2);
} catch (final MailException e) {
throw new PublishException("Failed to send event notification to mail: " + getTo(), e);
}
}
示例12: run
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
public void run() {
logger.info("Listing images in image database, scheduled by Timer");
List images = this.imageDatabase.getImages();
String[] imageNames = new String[images.size()];
for (int i = 0; i < images.size(); i++) {
ImageDescriptor image = (ImageDescriptor) images.get(i);
imageNames[i] = image.getName();
}
String text = "Images in image database: " + StringUtils.arrayToDelimitedString(imageNames, ", ");
logger.info(text);
if (!"".equals(this.mailTo)) {
logger.info("Sending image list mail to: " + this.mailTo);
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(this.mailFrom);
message.setTo(this.mailTo);
message.setSubject("Image list");
message.setText(text);
this.mailSender.send(message);
}
else {
logger.info("Not sending image list mail - specify mail settings in 'WEB-INF/mail.properties'");
}
}
示例13: sendMail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
/** 메일로 메세지를 보냄.
* @param to
* @param subject
* @param msg
*/
public void sendMail(String to, String subject, String msg) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(msg);
mailSender.send(message);
}
示例14: createEmail
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
private static void createEmail(int i) {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo("[email protected]");
message.setFrom("[email protected]");
message.setSubject("Test-Mail " + i);
message.setText("This is the test mail number "+i);
getEmailSender().send(message);
}
示例15: SendMailToCustom
import org.springframework.mail.SimpleMailMessage; //導入方法依賴的package包/類
@RequestMapping(path = "/mail/send", method = RequestMethod.POST)
public MailVo SendMailToCustom(@RequestBody MailVo vo) {
System.err.println(vo.getMail());
vo.setCode(RandomStringUtils.randomAscii(18));
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo(vo.getMail());
message.setSubject("主題:簡單測試郵件");
message.setText("測試郵件內容 驗證碼是:" + vo.getCode() + "\n" + vo.getMessage());
mailSender.send(message);
return vo;
}