本文整理汇总了Java中org.springframework.mail.SimpleMailMessage.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleMailMessage.setTo方法的具体用法?Java SimpleMailMessage.setTo怎么用?Java SimpleMailMessage.setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mail.SimpleMailMessage
的用法示例。
在下文中一共展示了SimpleMailMessage.setTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageTemplate
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
private SimpleMailMessage getMessageTemplate(MongoDbScenario scenario, Throwable ex)
{
Settings settings = settingsService.getSettings();
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(settings.getSmtpFrom());
mailMessage.setTo(settings.getAlarmEmails().split(","));
String body = "";
if (ex != null)
{
body += ex.toString() + "\n\n\n";
}
body += new JSONObject((scenario)).toString(4);
mailMessage.setText(body);
return mailMessage;
}
示例2: sendAdminEmailOnRoleChange
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
*
* Email Update on Role Change - Called when User Role is Changed
*
* @param certDn DN of the certificate that is being updated
* @param role New Role of Certificate
* @param cert_key Key of the updated Certificate
* @param userEmail E-mail address of local RA Manager / CA Manager
*/
public void sendAdminEmailOnRoleChange(String certDn, String role, long cert_key, String userEmail){
log.debug("sendAdminEmailOnRoleChange method");
StringBuilder emailDebug = new StringBuilder("Emailing new role [");
emailDebug.append(role);
// Create a thread safe "copy" of the template message and customize it
SimpleMailMessage msg = new SimpleMailMessage(this.emailTemplate);
msg.setTo(userEmail);
msg.setSubject("UK CA Role Updated");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("cert_dn", certDn);
vars.put("basePortalUrl", basePortalUrl);
vars.put("req_key", cert_key);
vars.put("new_role", role);
try {
this.mailSender.send(msg, vars, this.emailAdminsRoleChangeTemplate);
} catch (MailException ex) {
log.error("MailSender " + ex.getMessage());
}
emailDebug.append("]");
log.debug(emailDebug);
}
示例3: 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);
}
示例4: doRegister
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
@RequestMapping(value = "/register", method = RequestMethod.POST)
public String doRegister(@Valid @ModelAttribute UserModel newUserModel, BindingResult bindingResult, Model model) {
if (newUserModel.getPassword().length() < 14)
return "register2";
else {
// Password encryption
newUserModel.setPassword(passwordEncoder.encode(newUserModel.getPassword()));
userRepository.save(newUserModel);
// Create user-role for the user
UserRoleModel role = new UserRoleModel();
role.setRole("ROLE_USER");
role.setUser(newUserModel);
userRoleRepository.save(role);
//Send verification mail
SimpleMailMessage msg = new SimpleMailMessage(this.customMailMessage);
msg.setTo(newUserModel.getEmail_address());
msg.setText(String.format(msg.getText(), newUserModel.getUsername(), "http://localhost:8080/Towan/verification?id="+newUserModel.getUserId()));
this.mailSender.send(msg);
return "verifyInfo";
}
}
示例5: 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);
log.info("邮件发送成功!");
} catch (Exception e) {
log.error("邮件发送失败!");
log.error("失败原因:{}", e);
}
}
示例6: sendSimpleMail
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
* 发送文本邮件 setCc 抄送 setBcc 密送
*/
@Async("mailAsync")
public void sendSimpleMail(String to, String subject, String content) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setBcc(from);
message.setSubject(subject);
message.setText(content);
message.setSentDate(new Date());
try {
mailSender.send(message);
logger.info("简单邮件已经发送。");
} catch (Exception e) {
logger.error("发送简单邮件时发生异常!", e);
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: sendMessage
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
public boolean sendMessage(String mailFrom, String mailTo, String subject, String mailMessage) {
SimpleMailMessage mail = new SimpleMailMessage();
if(this.isEnabled) {
try {
mail.setFrom(mailFrom);
mail.setTo(mailTo);
mail.setSubject(subject);
mail.setText(mailMessage);
mailSender.send(mail);
log.debug("Email sent : " + mail.toString());
//logService.logMail(mailTo, mailMessage, LogService.MAIL_SENT);
} catch(Exception e) {
log.error("Email failed : " + mail.toString(), e);
//logService.logMail(mailTo, mailMessage, LogService.MAIL_FAILED);
return false;
}
} else {
log.warn("sendMessage called but email is not enabled ...");
log.info("\tmethod call was : sendMessage(" + mailFrom + ", " + mailTo + ", " + subject + ", " + mailMessage + ")");
}
return true;
}
示例10: sendmail
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
@RequestMapping(value = "sendmail", method = RequestMethod.POST, produces = { "application/xml", "application/json" })
public ResponseEntity<Email> sendmail(@RequestBody Email email) {
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
javaMailSender.setHost(email.getHost());
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(email.getFrom());
message.setTo(email.getTo());
message.setSubject(email.getSubject());
message.setText(email.getText());
try{
javaMailSender.send(message);
email.setStatus(true);
}catch(Exception e){
email.setText(e.getMessage());
email.setStatus(false);
}
return new ResponseEntity<Email>(email, HttpStatus.OK);
}
示例11: 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");
}
示例12: 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);
}
示例13: 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);
}
}
示例14: sendEmailForForgotPassword
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
* Sends email with the token to change password
*
* @see edu.ur.ir.user.UserService#sendEmailForForgotPassword(String, String)
*/
public void sendEmailForForgotPassword(String token, String email) {
SimpleMailMessage message = new SimpleMailMessage(passwordTokenMessage);
message.setTo(email);
String text = message.getText();
text = StringUtils.replace(text, "%TOKEN%", token);
text = StringUtils.replace(text, "%BASE_WEB_APP_PATH%", baseWebAppPath);
message.setText(text);
try {
mailSender.send(message);
} catch (Exception e) {
log.error(e.getMessage());
throw new IllegalStateException(e);
}
}
示例15: sendRequestorOnNewUser
import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
* Email the user of their CSR request.
* @param dn DN of the new CSR
* @param recipientEmail
* @param raCNs
* @param raEmails
*/
public void sendRequestorOnNewUser(String dn,
String recipientEmail, String raCNs, String raEmails) {
SimpleMailMessage msg = new SimpleMailMessage(this.emailTemplate);
msg.setTo(recipientEmail);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("cn", CertUtil.extractDnAttribute(dn, CertUtil.DNAttributeType.CN));
vars.put("dn", dn);
vars.put("raCNs", raCNs);
vars.put("raEmails", raEmails);
try {
this.mailSender.send(msg, vars, this.emailUserNewUserCertTemplate);
} catch (MailException ex) {
log.error("MailSender " + ex.getMessage());
}
}