use of org.springframework.mail.SimpleMailMessage in project spring-integration by spring-projects.
the class MailSendingMessageHandlerTests method simpleMailMessageOverrideWithHeaders.
@Test
public void simpleMailMessageOverrideWithHeaders() {
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
mailMessage.getTo();
this.handler.handleMessage(MessageBuilder.withPayload(mailMessage).setHeader(MailHeaders.TO, new String[] { "foo@bar.bam" }).build());
assertEquals("only one simple message must be sent", 1, mailSender.getSentSimpleMailMessages().size());
SimpleMailMessage sentMessage = mailSender.getSentSimpleMailMessages().get(0);
assertTrue(sentMessage.getTo()[0].equals("foo@bar.bam"));
}
use of org.springframework.mail.SimpleMailMessage in project spring-integration by spring-projects.
the class MailSendingMessageHandlerTests method simpleMailMessage.
@Test
public void simpleMailMessage() {
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
String[] toHeaders = mailMessage.getTo();
this.handler.handleMessage(MessageBuilder.withPayload(mailMessage).build());
assertEquals("only one simple message must be sent", 1, mailSender.getSentSimpleMailMessages().size());
SimpleMailMessage sentMessage = mailSender.getSentSimpleMailMessages().get(0);
assertTrue(sentMessage.getTo().equals(toHeaders));
}
use of org.springframework.mail.SimpleMailMessage in project onebusaway-application-modules by camsys.
the class ForgotPasswordAction method getMessage.
private SimpleMailMessage getMessage() {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(username);
msg.setSubject(EMAIL_SUBJECT);
String tempPass = _passwordService.getTemporaryPasswordForUser(username);
msg.setText(getEmailBody(tempPass));
return msg;
}
use of org.springframework.mail.SimpleMailMessage in project Spring-Family by Sierou-Java.
the class MainServiceImpl method sendEmail.
/**
* 发送Email服务
*
* @param content 内容
* @param to 接受者
* @param subject 主题
* @return
*/
@Override
public Boolean sendEmail(String content, String to, String subject) {
Boolean flag = false;
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(content);
try {
mailSender.send(message);
flag = true;
logger.info("简单邮件已经发送。");
} catch (Exception e) {
logger.error("发送简单邮件时发生异常!", e);
}
return flag;
}
use of org.springframework.mail.SimpleMailMessage in project cia by Hack23.
the class EmailServiceImpl method sendEmail.
@Override
public void sendEmail(final String toEmail, final String subject, final String content) {
final ApplicationConfiguration sendEmail = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SEND_EMAILS, SEND_EMAIL, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SEND_EMAIL, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SEND_EMAIL, "false");
final ApplicationConfiguration fromEmail = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_FROM_EMAIL, FROM_EMAIL, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SEND_EMAIL, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_FROM_EMAIL, "admin@hack23.com");
final JavaMailSender javaMailSender = getMailSender();
final SimpleMailMessage emailMessage = new SimpleMailMessage();
emailMessage.setFrom(fromEmail.getPropertyValue());
emailMessage.setTo(toEmail);
emailMessage.setText(content);
emailMessage.setSubject(subject);
if ("true".equalsIgnoreCase(sendEmail.getPropertyValue())) {
LOGGER.info("Sending email:{}", emailMessage);
javaMailSender.send(emailMessage);
} else {
LOGGER.info("Email sending disabled, do not send email:{}", emailMessage);
}
}
Aggregations