use of org.springframework.mail.SimpleMailMessage in project tutorials by eugenp.
the class SpringBootMailIntegrationTest method composeEmailMessage.
private SimpleMailMessage composeEmailMessage() {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(userTo);
mailMessage.setReplyTo(userFrom);
mailMessage.setFrom(userFrom);
mailMessage.setSubject(subject);
mailMessage.setText(textMail);
return mailMessage;
}
use of org.springframework.mail.SimpleMailMessage in project tutorials by eugenp.
the class AppConfig method templateSimpleMessage.
@Bean
public SimpleMailMessage templateSimpleMessage() {
SimpleMailMessage message = new SimpleMailMessage();
message.setText("This is the test email template for your email:\n%s\n");
return message;
}
use of org.springframework.mail.SimpleMailMessage in project tutorials by eugenp.
the class EmailServiceImpl method sendSimpleMessage.
public void sendSimpleMessage(String to, String subject, String text) {
try {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(text);
emailSender.send(message);
} catch (MailException exception) {
exception.printStackTrace();
}
}
use of org.springframework.mail.SimpleMailMessage in project spring-boot-examples by ityouknow.
the class MailServiceImpl method sendSimpleMail.
/**
* 发送文本邮件
* @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);
logger.info("简单邮件已经发送。");
} catch (Exception e) {
logger.error("发送简单邮件时发生异常!", e);
}
}
use of org.springframework.mail.SimpleMailMessage in project spring-integration by spring-projects.
the class MailSendingMessageHandlerContextTests method stringMessagesWithConfiguration.
@Test
public void stringMessagesWithConfiguration() {
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
assertEquals("no mime message should have been sent", 0, this.mailSender.getSentMimeMessages().size());
assertEquals("only one simple message must be sent", 1, this.mailSender.getSentSimpleMailMessages().size());
assertEquals("message content different from expected", mailMessage, this.mailSender.getSentSimpleMailMessages().get(0));
}
Aggregations