本文整理汇总了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;
}