Java Code Examples for org.springframework.mail.SimpleMailMessage

The following examples show how to use org.springframework.mail.SimpleMailMessage. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Mario   Source File: MailServiceTest.java    License: Apache License 2.0 7 votes vote down vote up
/**
 * 多附件邮件测试
 * 
 * @throws MessagingException
 * @throws InterruptedException
 * @throws IOException
 */
@Test
public void testSendMailMultiFiles() throws MessagingException, InterruptedException,
        IOException {
    SimpleMailMessage message = buildSimpleMessage();
    String[] files = new String[] { EMAIL_ATTACHMENT, EMAIL_ATTACHMENT };
    mimeMailService.sendMailFiles(message, files);

    greenMail.waitForIncomingEmail(2000, 1);

    MimeMessage[] msgs = greenMail.getReceivedMessages();
    MimeMultipart mimeMultipart = (MimeMultipart) msgs[0].getContent();

    assertEquals(1, msgs.length);
    assertEquals(MAIL_MESSAGE_FROM, msgs[0].getFrom()[0].toString());
    assertEquals(MAIL_MESSAGE_SUBJECT, msgs[0].getSubject());
    assertEquals(3, mimeMultipart.getCount());//multipart个数
    assertTrue(GreenMailUtil.getBody(mimeMultipart.getBodyPart(0)).trim()
            .contains(MAIL_MESSAGE_CONTEXT));
    assertEquals("Hello,i am a attachment.", GreenMailUtil
            .getBody(mimeMultipart.getBodyPart(1)).trim());
    assertEquals("Hello,i am a attachment.", GreenMailUtil
            .getBody(mimeMultipart.getBodyPart(2)).trim());
}
 
Example 2
Source Project: SpringBootLearn   Source File: MailTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 发送简单邮件
 */
@Test
public void sendSimpleMail() {
    SimpleMailMessage message = new SimpleMailMessage();
    //设定邮件参数
    //发送者
    message.setFrom(username);
    //接收者
    message.setTo("[email protected]");
    //主题
    message.setSubject("测试主题");
    //邮件内容
    message.setText("测试内容");
    // 发送邮件
    javaMailSender.send(message);
}
 
Example 3
Source Project: jsflight   Source File: EmailNotificationService.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source Project: fake-smtp-server   Source File: JavaMailSenderFacadeTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSendSimpleMessageWhenMailSystemIsAvailable() {
    var javaMailSender = mock(JavaMailSender.class);
    var logger = mock(Logger.class);
    var message = mock(SimpleMailMessage.class);

    var sut = new JavaMailSenderFacade();
    sut.setJavaMailSender(javaMailSender);
    sut.setLogger(logger);

    sut.send(message);

    verify(javaMailSender).send(message);
    verifyNoMoreInteractions(javaMailSender);
    verifyNoInteractions(logger);
}
 
Example 5
Source Project: spring4-understanding   Source File: JavaMailSenderTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void failedMailServerClose() throws Exception {
	MockJavaMailSender sender = new MockJavaMailSender();
	sender.setHost("");
	sender.setUsername("username");
	sender.setPassword("password");
	SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
	try {
		sender.send(simpleMessage1);
		fail("Should have thrown MailSendException");
	}
	catch (MailSendException ex) {
		// expected
		ex.printStackTrace();
		assertTrue(ex.getFailedMessages() != null);
		assertEquals(0, ex.getFailedMessages().size());
	}
}
 
Example 6
Source Project: spring-boot-study   Source File: MailController.java    License: MIT License 6 votes vote down vote up
/**
 * 发送文本标题 文本内容
 * */
@GetMapping("/sendMail")
public String sendMail(){
    try{

        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(sendUser);
        message.setTo("[email protected]");
        message.setSubject("主题邮件");
        message.setText("邮件内容");
        mailSender.send(message);
        return "success";
    }catch (Exception e){
        e.printStackTrace();
        return "fail";
    }
}
 
Example 7
/**
 * 处理简单邮件类型
 *
 * @param message 邮件内容
 * @return boolean
 */
private boolean processSimpleEmail(EmailMessage message) {
	// 注意邮件发送可能出现异常,注意catch
	try {
		SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
		simpleMailMessage.setFrom("\"" + message.getFrom() + "\" <" + username + ">");
		simpleMailMessage.setTo(ArrayUtil.toArray(message.getTos(), String.class));
		simpleMailMessage.setSubject(message.getSubject());
		simpleMailMessage.setText(message.getContent());

		// 设置抄送人列表
		if (CollUtil.isEmpty(message.getCcs())) {
			simpleMailMessage.setCc(ArrayUtil.toArray(message.getCcs(), String.class));
		}
		mailSender.send(simpleMailMessage);
		return true;
	} catch (Exception e) {
		log.error("简单邮件发送异常!", e);
		return false;
	}
}
 
Example 8
Source Project: spring-boot-examples   Source File: EmailAction.java    License: Apache License 2.0 6 votes vote down vote up
@PostMapping(value = "simple")
public String sendSimpleMsg(String msg, String email) {
    if (StringUtils.isEmpty(msg) || StringUtils.isEmpty(email)) {
        return "请输入要发送消息和目标邮箱";
    }

    try {
        SimpleMailMessage mail = new SimpleMailMessage();
        mail.setFrom(sendName);
        mail.setTo(email);
        mail.setSubject("这是一封简单邮件");
        mail.setText(msg);
        mailSender.send(mail);
        return "发送成功";
    } catch (Exception ex) {
        ex.printStackTrace();
        return "发送失败:" + ex.getMessage();
    }
}
 
Example 9
/** Creates a MimeMessage based on a FeedbackForm. */
@SuppressWarnings("java:S3457") // do not use platform specific line ending
private SimpleMailMessage createFeedbackMessage(FeedbackForm form) {
  SimpleMailMessage message = new SimpleMailMessage();
  message.setTo(userService.getSuEmailAddresses().toArray(new String[] {}));
  if (form.hasEmail()) {
    message.setCc(form.getEmail());
    message.setReplyTo(form.getEmail());
  } else {
    message.setReplyTo("[email protected]");
  }
  String appName = appSettings.getTitle();
  message.setSubject(String.format("[feedback-%s] %s", appName, form.getSubject()));
  message.setText(String.format("Feedback from %s:\n\n%s", form.getFrom(), form.getFeedback()));
  return message;
}
 
Example 10
Source Project: java-technology-stack   Source File: JavaMailSenderTests.java    License: MIT License 6 votes vote down vote up
@Test
public void failedMailServerConnect() {
	MockJavaMailSender sender = new MockJavaMailSender();
	sender.setHost(null);
	sender.setUsername("username");
	sender.setPassword("password");
	SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
	try {
		sender.send(simpleMessage1);
		fail("Should have thrown MailSendException");
	}
	catch (MailSendException ex) {
		// expected
		ex.printStackTrace();
		assertTrue(ex.getFailedMessages() != null);
		assertEquals(1, ex.getFailedMessages().size());
		assertSame(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
		assertSame(ex.getCause(), ex.getFailedMessages().values().iterator().next());
	}
}
 
Example 11
Source Project: pre   Source File: EmailUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void sendSimpleMail(String to, HttpServletRequest request) {
    SimpleMailMessage message = new SimpleMailMessage();
    //设定邮件参数
    //发送者
    message.setFrom(username);
    //接收者
    message.setTo(to);
    //主题
    message.setSubject("修改pre系统用户邮箱");
    //邮件内容
    // 验证码
    String code = PreUtil.codeGen(4);
    message.setText("【Pre系统】" + ",验证码:" + code + "。" + "你正在使用邮箱验证码修改功能,该验证码仅用于身份验证,请勿透露给他人使用");
    // 发送邮件
    javaMailSender.send(message);
    request.getSession().setAttribute(PreConstant.RESET_MAIL, code.toLowerCase());
}
 
Example 12
Source Project: spring4-understanding   Source File: JavaMailSenderTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void failedMailServerConnect() throws Exception {
	MockJavaMailSender sender = new MockJavaMailSender();
	sender.setHost(null);
	sender.setUsername("username");
	sender.setPassword("password");
	SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
	try {
		sender.send(simpleMessage1);
		fail("Should have thrown MailSendException");
	}
	catch (MailSendException ex) {
		// expected
		ex.printStackTrace();
		assertTrue(ex.getFailedMessages() != null);
		assertEquals(1, ex.getFailedMessages().size());
		assertSame(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
		assertSame(ex.getCause(), ex.getFailedMessages().values().iterator().next());
	}
}
 
Example 13
Source Project: rice   Source File: MailerImpl.java    License: Educational Community License v2.0 6 votes vote down vote up
/**
    * Construct and a send simple email message from a Mail Message.
    * 
    * @param message
    *            the Mail Message
 * @throws MessagingException 
    */
@Override
      @SuppressWarnings("unchecked")
public void sendEmail(MailMessage message) throws MessagingException {
       
       // Construct a simple mail message from the Mail Message
       SimpleMailMessage smm = new SimpleMailMessage();
       smm.setTo( (String[])message.getToAddresses().toArray(new String[message.getToAddresses().size()]) );
       smm.setBcc( (String[])message.getBccAddresses().toArray(new String[message.getBccAddresses().size()]) );
       smm.setCc( (String[])message.getCcAddresses().toArray(new String[message.getCcAddresses().size()]) );
       smm.setSubject(message.getSubject());
       smm.setText(message.getMessage());
       smm.setFrom(message.getFromAddress());

       try {
       	if ( LOG.isDebugEnabled() ) {
       		LOG.debug( "sendEmail() - Sending message: " + smm.toString() );
       	}
           mailSender.send(smm);
       }
       catch (Exception e) {
       	LOG.error("sendEmail() - Error sending email.", e);
		throw new RuntimeException(e);
       }
   }
 
Example 14
@Test
void testSendMultipleMailsWithExceptionWhileSending() throws Exception {
	AmazonSimpleEmailService emailService = mock(AmazonSimpleEmailService.class);
	SimpleEmailServiceMailSender mailSender = new SimpleEmailServiceMailSender(
			emailService);

	SimpleMailMessage firstMessage = createSimpleMailMessage();
	firstMessage.setBcc("[email protected]");

	SimpleMailMessage failureMail = createSimpleMailMessage();
	when(emailService.sendEmail(ArgumentMatchers.isA(SendEmailRequest.class)))
			.thenReturn(new SendEmailResult())
			.thenThrow(new AmazonClientException("error"))
			.thenReturn(new SendEmailResult());

	SimpleMailMessage thirdMessage = createSimpleMailMessage();

	try {
		mailSender.send(firstMessage, failureMail, thirdMessage);
		fail("Exception expected due to error while sending mail");
	}
	catch (MailSendException e) {
		assertThat(e.getFailedMessages().size()).isEqualTo(1);
		assertThat(e.getFailedMessages().containsKey(failureMail)).isTrue();
	}
}
 
Example 15
Source Project: Mario   Source File: MailServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 一个附件的邮件测试
 * 
 * @throws MessagingException
 * @throws InterruptedException
 * @throws IOException
 */
@Test
public void testSendMailFiles() throws MessagingException, InterruptedException, IOException {
    SimpleMailMessage message = buildSimpleMessage();
    String[] files = new String[] { EMAIL_ATTACHMENT };
    mimeMailService.sendMailFiles(message, files);

    greenMail.waitForIncomingEmail(2000, 1);

    MimeMessage[] msgs = greenMail.getReceivedMessages();
    MimeMultipart mimeMultipart = (MimeMultipart) msgs[0].getContent();

    assertEquals(1, msgs.length);
    assertEquals(MAIL_MESSAGE_FROM, msgs[0].getFrom()[0].toString());
    assertEquals(MAIL_MESSAGE_SUBJECT, msgs[0].getSubject());
    assertEquals(2, mimeMultipart.getCount());//multipart个数
    assertTrue(GreenMailUtil.getBody(mimeMultipart.getBodyPart(0)).trim()
            .contains(MAIL_MESSAGE_CONTEXT));
    assertEquals("Hello,i am a attachment.", GreenMailUtil
            .getBody(mimeMultipart.getBodyPart(1)).trim());
}
 
Example 16
@Test
void testMailFailed() {
  jobExecution.setFailureEmail("[email protected],[email protected]");
  progress.start();
  progress.status("Working....");
  Exception ex = new IllegalArgumentException("blah");
  progress.failed("blah", ex);
  System.out.println(jobExecution.getLog());
  assertTrue(jobExecution.getLog().contains("- Execution started." + System.lineSeparator()));
  assertTrue(jobExecution.getLog().contains("- Working...." + System.lineSeparator()));
  assertTrue(jobExecution.getLog().contains("- Failed"));
  assertTrue(jobExecution.getLog().contains(ex.getMessage()));

  SimpleMailMessage mail = new SimpleMailMessage();
  mail.setTo(new String[] {"[email protected]", "[email protected]"});
  mail.setSubject("Annotator job failed.");
  mail.setText(jobExecution.getLog());
  verify(mailSender).send(mail);
}
 
Example 17
Source Project: yunsleLive_room   Source File: MailServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
public boolean sendMail(String address, String content) {
    try {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("[email protected]");
        message.setTo(address);
        message.setSubject("主题:忘记密码");
        message.setText("Hi,你好。这是你的密码:"+content+" 请注意密码安全,及时修改!");
        mailSender.send(message);
        return true;
    } catch (Exception e) {
        System.err.println("sendMail错误:"+e);
        return false;
    }

}
 
Example 18
Source Project: shark   Source File: SendMail.java    License: Apache License 2.0 6 votes vote down vote up
public SendMail() {
	mailBean = new MailBean();
	mailSender = new JavaMailSenderImpl();
	mailSender.setPort(mailBean.getPORT());
	mailSender.setHost(mailBean.getHOST());
	mailSender.setUsername(mailBean.getUSERNAME());
	mailSender.setPassword(mailBean.getPASSWORD());
	Properties properties = new Properties();
	properties.setProperty("mail.smtp.auth", "true");
	mailSender.setJavaMailProperties(properties);
	mailMessage = new SimpleMailMessage();
	mailMessage.setFrom(mailBean.getFROM());
	mailMessage.setTo(mailBean.getTO());
	mailMessage.setSubject(mailBean.getSUBJECT());
	GetUserInfo getUserInfo = new GetUserInfo();
	mailMessage.setText("[version]:" + LoadVersion.getVersion() + "\n[javaVersion]:" + getUserInfo.getJavaVersion()
			+ "\n[osName]:" + getUserInfo.getOsName() + "\n[jvmName]:" + getUserInfo.getJvmName() + "\n[address]:"
			+ getUserInfo.getAddress() + "\n[hostName]:" + getUserInfo.getHostname() + "\n[startTime]:"
			+ getUserInfo.getStartTime());
}
 
Example 19
Source Project: Mario   Source File: MailServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * MimeMessage格式邮件发送
 * 
 * @throws Exception
 */
@Test
public void testSendMail() throws Exception {
    SimpleMailMessage message = buildSimpleMessage();
    mimeMailService.sendMail(message);

    greenMail.waitForIncomingEmail(2000, 1);

    MimeMessage[] msgs = greenMail.getReceivedMessages();
    MimeMultipart mimeMultipart = (MimeMultipart) msgs[0].getContent();

    assertEquals(1, msgs.length);
    assertEquals(MAIL_MESSAGE_FROM, msgs[0].getFrom()[0].toString());
    assertEquals(MAIL_MESSAGE_SUBJECT, msgs[0].getSubject());
    assertTrue(GreenMailUtil.getBody(mimeMultipart.getBodyPart(0)).trim()
            .contains(MAIL_MESSAGE_CONTEXT));
}
 
Example 20
Source Project: DouBiNovel   Source File: MailServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 21
Source Project: ChengFeng1.5   Source File: MailSenderUtil.java    License: MIT License 5 votes vote down vote up
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("发送简单邮件时发⽣异常!", e);
    }
}
 
Example 22
Source Project: springboot-learn   Source File: MailServiceImpl.java    License: MIT License 5 votes vote down vote up
@Async
@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);
    } catch (Exception e) {
        logger.error("发送简单邮件时发生异常!", e);
    }
}
 
Example 23
Source Project: spring4-understanding   Source File: JavaMailSenderTests.java    License: Apache License 2.0 5 votes vote down vote up
public void testJavaMailSenderWithSimpleMessages() throws MessagingException, IOException {
	MockJavaMailSender sender = new MockJavaMailSender();
	sender.setHost("host");
	sender.setUsername("username");
	sender.setPassword("password");

	SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
	simpleMessage1.setTo("[email protected]");
	SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
	simpleMessage2.setTo("[email protected]");
	sender.send(simpleMessage1, simpleMessage2);

	assertEquals("host", sender.transport.getConnectedHost());
	assertEquals("username", sender.transport.getConnectedUsername());
	assertEquals("password", sender.transport.getConnectedPassword());
	assertTrue(sender.transport.isCloseCalled());

	assertEquals(2, sender.transport.getSentMessages().size());
	MimeMessage sentMessage1 = sender.transport.getSentMessage(0);
	List<Address> tos1 = Arrays.asList(sentMessage1.getRecipients(Message.RecipientType.TO));
	assertEquals(1, tos1.size());
	assertEquals("[email protected]", ((InternetAddress) tos1.get(0)).getAddress());
	MimeMessage sentMessage2 = sender.transport.getSentMessage(1);
	List<Address> tos2 = Arrays.asList(sentMessage2.getRecipients(Message.RecipientType.TO));
	assertEquals(1, tos2.size());
	assertEquals("[email protected]", ((InternetAddress) tos2.get(0)).getAddress());
}
 
Example 24
Source Project: fake-smtp-server   Source File: JavaMailSenderFacadeTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldLogErrorAndSkipSendingOfSimpleMessageWhenMailSystemIsNotAvailable() {
    var logger = mock(Logger.class);
    var message = mock(SimpleMailMessage.class);

    var sut = new JavaMailSenderFacade();
    sut.setLogger(logger);

    sut.send(message);

    verify(logger).error(JavaMailSenderFacade.ERROR_MESSAGE);
    verifyNoMoreInteractions(logger);
}
 
Example 25
Source Project: fake-smtp-server   Source File: MessageForwarderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldForwardEmailAsSimpleMessageWhenForwardingIsEnabledAndEmailCannotBeConvertedToMimeMessage() throws Exception {
    var expectedException = new MessagingException("test");
    var from = "from";
    var to = "to";
    var content = "content";
    var rawData = mock(RawData.class);
    when(rawData.getFrom()).thenReturn(from);
    when(rawData.getTo()).thenReturn(to);
    when(rawData.getContentAsString()).thenReturn(content);
    when(rawData.toMimeMessage()).thenThrow(expectedException);
    when(configurationProperties.isForwardEmails()).thenReturn(true);

    sut.forward(rawData);

    verify(rawData).toMimeMessage();
    verify(javaMailSenderFacade, never()).send(any(MimeMessage.class));
    verify(logger).warn(anyString(), eq(expectedException));
    verify(rawData).getFrom();
    verify(rawData).getTo();
    verify(rawData).getContentAsString();
    var mailMessageArgumentCaptor = ArgumentCaptor.forClass(SimpleMailMessage.class);
    verify(javaMailSenderFacade).send(mailMessageArgumentCaptor.capture());
    verifyNoMoreInteractions(rawData, javaMailSenderFacade);

    var message = mailMessageArgumentCaptor.getValue();
    assertEquals(from, message.getFrom());
    assertEquals(to, message.getTo()[0]);
    assertEquals(content, message.getText());
}
 
Example 26
Source Project: attic-rave   Source File: DefaultEmailService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void sendEmail(String to, String subject, String templateName, Map<String, Object> templateData) {
    // create a copy of mail message:
    SimpleMailMessage message = new SimpleMailMessage(emailServiceMailMessage);
    message.setSubject(subject);
    message.setTo(to);
    // set body text:
    Configuration configuration = freemarkerMailConfiguration.getObject();
    String text = parseTemplate(configuration, templateData, templateName);
    message.setText(text);
    // send email:
    mailSender.send(message);
}
 
Example 27
private void sendPasswordResetMail(User user, String token) {
  URI passwordResetUri = createPasswordResetUri(user.getUsername(), token);

  SimpleMailMessage mailMessage = new SimpleMailMessage();
  mailMessage.setTo(user.getEmail());
  mailMessage.setSubject(String.format("Password reset on %s", appSettings.getTitle()));
  mailMessage.setText(
      "Hello,\n\nYou are receiving this email because we received a password reset request for your account.\n\n"
          + passwordResetUri.toString()
          + "\n\nIf you did not request a password reset, you can safely ignore this email.");
  mailSender.send(mailMessage);
}
 
Example 28
private SimpleMailMessage createSimpleMailMessage() {
	SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
	simpleMailMessage.setFrom("[email protected]");
	simpleMailMessage.setTo("[email protected]");
	simpleMailMessage.setSubject("message subject");
	simpleMailMessage.setText("message body");
	return simpleMailMessage;
}
 
Example 29
Source Project: spring-boot-demo   Source File: MailServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 发送文本邮件
 *
 * @param to      收件人地址
 * @param subject 邮件主题
 * @param content 邮件内容
 * @param cc      抄送地址
 */
@Override
public void sendSimpleMail(String to, String subject, String content, String... cc) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(content);
    if (ArrayUtil.isNotEmpty(cc)) {
        message.setCc(cc);
    }
    mailSender.send(message);
}
 
Example 30
Source Project: springBoot   Source File: SpringBootMailServiceImpl.java    License: MIT License 5 votes vote down vote up
@Override
public void sendSimpleMail(String to, String subject, String text) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(text);

    mailSender.send(message);
}