当前位置: 首页>>代码示例>>Java>>正文


Java JavaMailSenderImpl.send方法代码示例

本文整理汇总了Java中org.springframework.mail.javamail.JavaMailSenderImpl.send方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMailSenderImpl.send方法的具体用法?Java JavaMailSenderImpl.send怎么用?Java JavaMailSenderImpl.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mail.javamail.JavaMailSenderImpl的用法示例。


在下文中一共展示了JavaMailSenderImpl.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRun

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Override
public void doRun(Collection<HealthCheck> healthChecks) {
    if (!healthChecks.isEmpty()) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);
        message.setSubject(subjectPrefix + " : " + healthChecks.size() + " failing checks");
        message.setTo(to);

        message.setText(buildMailContent(healthChecks));

        JavaMailSenderImpl sender = new JavaMailSenderImpl();
        sender.setHost(smtpHost);
        sender.setPort(smtpPort);

        userName.ifPresent(name -> sender.setUsername(name));
        pwd.ifPresent(pwd -> sender.setPassword(pwd));

        sender.send(message);
        logger.info("Notification mail sent for " + healthChecks.size() + " health checks");
    }
}
 
开发者ID:gilles-stragier,项目名称:quickmon,代码行数:22,代码来源:MailNotifier.java

示例2: sendEmailMsg

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的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

示例3: resetPassword

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@RequestMapping(value = "/login/resetPassword", method = RequestMethod.POST)
@ResponseBody
public GenericResponse resetPassword(HttpServletRequest request, @RequestParam("email") String userEmail) {
    UserToolsService userService = new UserToolsService();
    User user = userService.findUserByEmail(userEmail);
    if( user == null ) {
        throw new UserNotFoundException("User could not be found by email");
    }

    String token = UUID.randomUUID().toString();
    userService.createPasswordResetTokenForUser(user, token);
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.send(constructResetTokenEmail("temptext", request.getLocale(), token, user));
    return new GenericResponse(messages.getMessage("message.resetPasswordEmail", null, request.getLocale()));
    //return new GenericResponse("Temporary email response");
}
 
开发者ID:MTUHIDE,项目名称:CoCoTemp,代码行数:17,代码来源:ResetPasswordController.java

示例4: sendmail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的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

示例5: send

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public boolean send(String to, String subject, String text, String unsubscribeUrl) {
	try {
		JavaMailSenderImpl sender = (JavaMailSenderImpl) mailSender;
		MimeMessage mail = sender.createMimeMessage();
		mail.setContent(text.replaceAll("\n", "<br\\>\n").trim(),
				"text/html; charset=UTF-8");
		MimeMessageHelper helper = new MimeMessageHelper(mail, false,
				"UTF-8");
		helper.setFrom(from);
		helper.setTo(to);
		helper.setSubject(subject);
		if (null != unsubscribeUrl) {
			mail.addHeader("List-Unsubscribe", String.format("<%s>", unsubscribeUrl));
		}
		sender.send(mail);
		LOG.trace("E-mail sent with subject: {}", subject);
		return true;
	} catch (Exception ex) {
		LOG.warn("Failed to send email (subject: " + subject + ").", ex);
		return false;
	}
}
 
开发者ID:petabyte-research,项目名称:redflags,代码行数:23,代码来源:EmailSvc.java

示例6: sendMail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public void sendMail(final String from, final String to,
    final String subject, final String msg) throws MessagingException {

  // final SimpleMailMessage message = new SimpleMailMessage();
  // message.setFrom(from);
  // message.setTo(to);
  // message.setSubject(subject);
  // message.setText(msg);
  // mailSender.send(message);

  // final JavaMailSenderImpl sender = new JavaMailSenderImpl();
  mailSender = new JavaMailSenderImpl();
  final MimeMessage mimeMessage = mailSender.createMimeMessage();
  final MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false,
      "utf-8");
  final String htmlMsg = msg;
  mimeMessage.setContent(htmlMsg, "text/html");
  helper.setTo(to);
  helper.setSubject(subject);
  helper.setFrom(from);
  mailSender.send(mimeMessage);

}
 
开发者ID:AURIN,项目名称:workbenchauth,代码行数:24,代码来源:classMail.java

示例7: senderEmail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void senderEmail(final Integer uid, final String username,
		final String to, final String resetKey, final String resetPwd,
		final EmailSender email, final MessageTemplate tpl) {
	JavaMailSenderImpl sender = new JavaMailSenderImpl();
	sender.setHost(email.getHost());
	sender.setPort(email.getPort());
	sender.setUsername(email.getUsername());
	sender.setPassword(email.getPassword());
	sender.send(new MimeMessagePreparator() {
		public void prepare(MimeMessage mimeMessage)
				throws MessagingException, UnsupportedEncodingException {
			MimeMessageHelper msg = new MimeMessageHelper(mimeMessage,
					false, email.getEncoding());
			msg.setSubject(tpl.getForgotPasswordSubject());
			msg.setTo(to);
			msg.setFrom(email.getUsername(), email.getPersonal());
			String text = tpl.getForgotPasswordText();
			text = StringUtils.replace(text, "${uid}", String.valueOf(uid));
			text = StringUtils.replace(text, "${username}", username);
			text = StringUtils.replace(text, "${resetKey}", resetKey);
			text = StringUtils.replace(text, "${resetPwd}", resetPwd);
			msg.setText(text);
		}
	});
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:26,代码来源:UnifiedUserMngImpl.java

示例8: sendEmail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public void sendEmail() throws MessagingException {
    String email = backup.getEmail();
    JavaMailSenderImpl mailimpl = new JavaMailSenderImpl();
    mailimpl.setHost("smtp.163.com");
    MimeMessage mailMsg = mailimpl.createMimeMessage();
    MimeMessageHelper msgHelper = new MimeMessageHelper(mailMsg,true,"utf8");
    //set sender,receiver
    msgHelper.setTo(backup.getToemail());
    msgHelper.setFrom(email);
    msgHelper.setSubject("数据库备份");
    msgHelper.setText("<html><head></head><body><h1>数据库备份</h1></body></html>",true);

    msgHelper.addAttachment("study.sql",new File(backup.getSavePath() + File.separator + "study.sql"));
    msgHelper.addAttachment("blog.sql",new File(backup.getSavePath() + File.separator + "blog.sql"));

    mailimpl.setUsername(email);
    mailimpl.setPassword("liubo704");
    Properties prop = new Properties();
    prop.put("mail.smtp.auth",true);
    prop.put("mail.smtp.timeout","25000");

    mailimpl.setJavaMailProperties(prop);
    mailimpl.send(mailMsg);
}
 
开发者ID:ycsoft,项目名称:SweetHeart,代码行数:25,代码来源:BackupController.java

示例9: send

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public static void send(String to,String subject,String text) {
	// 获取JavaMailSender bean
	JavaMailSenderImpl sender = (JavaMailSenderImpl) ctx.getBean("mailSender");
	SimpleMailMessage mail = new SimpleMailMessage(); // <span															// style="color: #ff0000;">注意SimpleMailMessage只能用来发送text格式的邮件</span>
	try {
		mail.setFrom(sender.getUsername());
		mail.setTo(to);// 接受者
		mail.setSubject(subject);// 主题
		mail.setText(text);// 邮件内容
		sender.send(mail);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:dengxiangjun,项目名称:OfficeAutomation,代码行数:15,代码来源:MailUtil.java

示例10: sendMail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void sendMail(JavaMailSenderImpl mailSender, String mailFrom, String email, String subject, String message)
    throws IoTPException {
  try {
    MimeMessage mimeMsg = mailSender.createMimeMessage();
    MimeMessageHelper helper = new MimeMessageHelper(mimeMsg, "UTF-8");
    helper.setFrom(mailFrom);
    helper.setTo(email);
    helper.setSubject(subject);
    helper.setText(message, true);
    mailSender.send(helper.getMimeMessage());
  } catch (Exception e) {
    throw handleException(e);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:15,代码来源:DefaultMailService.java

示例11: forwardSmsByMail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void forwardSmsByMail(List<ReplaySms> msgs) {
    if (msgs == null) {
        return;
    }
    for (ReplaySms sms : msgs) {
        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(mailReceiver);
        mailMessage.setFrom(mailSender);
        mailMessage.setSubject(sms.getPhone());
        mailMessage.setText("用户回复消息,时间:" + sms.getDelivertime() + ",内容:" + sms.getContent());

        // 发送邮件
        senderImpl.send(mailMessage);

        logger.info("successfully send mail");
    }
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:31,代码来源:FetchReplaySmsTask.java

示例12: sendMessage

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void sendMessage(String subject) {
	JavaMailSenderImpl sender = new JavaMailSenderImpl();
	sender.setPort(8025);
	sender.setHost("localhost");
	SimpleMailMessage message = new SimpleMailMessage();
	message.setText("abcd");
	message.setSubject(subject);
	message.setFrom("[email protected]");
	message.setTo("[email protected]");
	sender.send(message);
}
 
开发者ID:quirinobrizi,项目名称:maileasy,代码行数:12,代码来源:MailEasyInterfaceImplTest.java

示例13: sendPlainText

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public static void sendPlainText(String to, String cc, String from, String subject, String text) {
    logger.info("sendPlainText");
    
    if (to.contains(",")) {
        to = to.replace(",", "");
    }
    if (to.contains(":")) {
        to = to.replace(":", "");
    }
            
    SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setTo(to);
    if (StringUtils.isNotBlank(cc)) {
        simpleMailMessage.setCc(cc);
    }
    simpleMailMessage.setBcc(ADMIN_EMAIL);
    simpleMailMessage.setFrom(from);
    simpleMailMessage.setSubject(subject);
    simpleMailMessage.setText(text);

    JavaMailSenderImpl javaMailSenderImpl = new JavaMailSenderImpl();
    String smtpHost = ConfigHelper.getProperty("smtp.host");
    javaMailSenderImpl.setHost(smtpHost);

    logger.info("Sending e-mail to " + simpleMailMessage.getTo()[0] + " with subject \"" + simpleMailMessage.getSubject() + "\"...");
    logger.info("Text: " + simpleMailMessage.getText());
    if (EnvironmentContextLoaderListener.env != Environment.DEV) {
        javaMailSenderImpl.send(simpleMailMessage);
    }
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:31,代码来源:Mailer.java

示例14: sendMail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void sendMail(JavaMailSenderImpl mailSender, 
        String mailFrom, String email, 
        String subject, String message) throws ThingsboardException {
    try {
        MimeMessage mimeMsg = mailSender.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(mimeMsg, UTF_8);
        helper.setFrom(mailFrom);
        helper.setTo(email);
        helper.setSubject(subject);
        helper.setText(message, true);
        mailSender.send(helper.getMimeMessage());
    } catch (Exception e) {
        throw handleException(e);
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:16,代码来源:DefaultMailService.java

示例15: send

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
/**
  * 
  */
@Override
public boolean send(String from, String to, String subject, String text) {
	boolean result = false;

	ResourceBundle rb = ResourceBundleUtils.getConfigBundle();
	String smtpServer = rb.getString("email.server.smtp");

	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
	mailSender.setHost(smtpServer);
	mailSender.setDefaultEncoding("UTF-8");

	SimpleMailMessage msg = new SimpleMailMessage();
	msg.setFrom(from);
	msg.setTo(to);
	msg.setSubject(subject);
	msg.setText(text);

	try {
		mailSender.send(msg);

		result = true;
		log.info("Odeslan email. From: " + from + ", to: " + to + ", subject: " + subject + ".");
	} catch (MailException exc) {
		log.error(exc.getMessage(), exc);
		result = false;
		log.info("NEodeslan email. From: " + from + ", to: " + to + ", subject: " + subject + ".");
	}

	return result;
}
 
开发者ID:CIT-VSB-TUO,项目名称:ResBill,代码行数:34,代码来源:MailSenderServiceImpl.java


注:本文中的org.springframework.mail.javamail.JavaMailSenderImpl.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。