use of org.springframework.mail.SimpleMailMessage in project spring-boot-admin by codecentric.
the class MailNotifierTest method test_onApplicationEvent.
@Test
public void test_onApplicationEvent() {
notifier.notify(new ClientApplicationStatusChangedEvent(Application.create("App").withId("-id-").withHealthUrl("http://health").build(), StatusInfo.ofDown(), StatusInfo.ofUp()));
SimpleMailMessage expected = new SimpleMailMessage();
expected.setTo(new String[] { "foo@bar.com" });
expected.setCc(new String[] { "bar@foo.com" });
expected.setFrom("SBA <no-reply@example.com>");
expected.setText("App (-id-)\nstatus changed from DOWN to UP\n\nhttp://health");
expected.setSubject("-id- is UP");
verify(sender).send(eq(expected));
}
use of org.springframework.mail.SimpleMailMessage in project spring-framework by spring-projects.
the class JavaMailSenderTests method testJavaMailSenderWithSimpleMessages.
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("he@mail.org");
SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
simpleMessage2.setTo("she@mail.org");
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("he@mail.org", ((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("she@mail.org", ((InternetAddress) tos2.get(0)).getAddress());
}
use of org.springframework.mail.SimpleMailMessage in project transporter by wang4ever.
the class MailSenderService method sendEmailMessageOfSimpleText.
/**
* 发送简单文本Email消息
*
* @param emailMsg
*/
public void sendEmailMessageOfSimpleText(MailMessage emailMsg, Date date) {
SimpleMailMessage simpleTextMessage = new SimpleMailMessage();
simpleTextMessage.setFrom(sender);
simpleTextMessage.setTo(emailMsg.getReceivers());
if (emailMsg.getBcc() != null && emailMsg.getBcc().length > 0)
simpleTextMessage.setBcc(emailMsg.getBcc());
if (emailMsg.getCc() != null && emailMsg.getCc().length > 0)
simpleTextMessage.setCc(emailMsg.getCc());
simpleTextMessage.setText(emailMsg.getEmailContent());
if (null == date)
date = new Date();
simpleTextMessage.setSentDate(date);
javaMailSender.send(simpleTextMessage);
}
use of org.springframework.mail.SimpleMailMessage in project code-chill by CodeChillAlluna.
the class UserController method updateEmailError.
// Method sending an error message for the former email adress
public boolean updateEmailError(String email) {
User user = urepo.findByEmail(email);
if (user != null) {
SimpleMailMessage infoUpdateFail = new SimpleMailMessage();
infoUpdateFail.setFrom(SENDFROM);
infoUpdateFail.setTo(user.getEmail());
infoUpdateFail.setSubject("Suspicious access to your account");
infoUpdateFail.setText("We have registered a suspicious activity on your acccount");
mailSender.send(infoUpdateFail);
return true;
}
return false;
}
use of org.springframework.mail.SimpleMailMessage in project Logos_Materials_October_2017 by VolodymyrZavada.
the class EmailServiceImpl method sendMessage.
@Override
public void sendMessage(Mail mail) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(mail.getFrom());
message.setTo(mail.getTo());
message.setSubject(mail.getSubject());
message.setText(mail.getContent());
mailSender.send(message);
}
Aggregations