當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleMailMessage.setTo方法代碼示例

本文整理匯總了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;
}
 
開發者ID:d0k1,項目名稱:jsflight,代碼行數:17,代碼來源:EmailNotificationService.java

示例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);
}
 
開發者ID:UKCA,項目名稱:CAPortal,代碼行數:32,代碼來源:EmailService.java

示例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);
}
 
開發者ID:Exercon,項目名稱:AntiSocial-Platform,代碼行數:17,代碼來源:RegistrationListener.java

示例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";
	}
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:27,代碼來源:RegisterController.java

示例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);
    }
}
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:24,代碼來源:MailServiceImpl.java

示例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);
	}

}
 
開發者ID:CharleyXu,項目名稱:tulingchat,代碼行數:21,代碼來源:MailUtil.java

示例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);
    }
}
 
開發者ID:JavaTrainingCourse,項目名稱:obog-manager,代碼行數:26,代碼來源:MailService.java

示例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);
    }
}
 
開發者ID:JavaTrainingCourse,項目名稱:obog-manager,代碼行數:25,代碼來源:MailService.java

示例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;
  }
 
開發者ID:EsupPortail,項目名稱:esup-sgc,代碼行數:25,代碼來源:EmailService.java

示例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);
}
 
開發者ID:oscm,項目名稱:web,代碼行數:20,代碼來源:EmailRestController.java

示例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");
}
 
開發者ID:booleguo,項目名稱:sam-elle,代碼行數:27,代碼來源:EmailSendServiceImpl.java

示例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);
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:17,代碼來源:SpringMailSenderBackend.java

示例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);
    }
}
 
開發者ID:alibaba,項目名稱:yugong,代碼行數:22,代碼來源:MailAlarmService.java

示例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);
	}
}
 
開發者ID:nate-rcl,項目名稱:irplus,代碼行數:22,代碼來源:DefaultUserService.java

示例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());
    }
}
 
開發者ID:UKCA,項目名稱:CAPortal,代碼行數:25,代碼來源:EmailService.java


注:本文中的org.springframework.mail.SimpleMailMessage.setTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。