use of org.springframework.mail.SimpleMailMessage in project spring-integration by spring-projects.
the class MailSendingMessageHandlerTests method textMessage.
@Test
public void textMessage() {
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
assertEquals("no mime message should have been sent", 0, mailSender.getSentMimeMessages().size());
assertEquals("only one simple message must be sent", 1, mailSender.getSentSimpleMailMessages().size());
assertEquals("message content different from expected", mailMessage, mailSender.getSentSimpleMailMessages().get(0));
}
use of org.springframework.mail.SimpleMailMessage in project spring-integration by spring-projects.
the class MailSendingMessageHandlerTests method mailHeaders.
@Test
public void mailHeaders() {
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
assertEquals("no mime message should have been sent", 0, mailSender.getSentMimeMessages().size());
assertEquals("only one simple message must be sent", 1, mailSender.getSentSimpleMailMessages().size());
assertEquals("message content different from expected", mailMessage, mailSender.getSentSimpleMailMessages().get(0));
}
use of org.springframework.mail.SimpleMailMessage in project otter by alibaba.
the class DefaultAlarmService method doSend.
public void doSend(AlarmMessage data) throws Exception {
// 只发送纯文本
SimpleMailMessage mail = new SimpleMailMessage();
mail.setFrom(username);
// 主题
mail.setSubject(TITLE);
// 邮件内容
mail.setText(data.getMessage());
String[] receiveKeys = StringUtils.split(StringUtils.replace(data.getReceiveKey(), ";", ","), ",");
SystemParameter systemParameter = systemParameterService.find();
List<String> mailAddress = new ArrayList<String>();
for (String receiveKey : receiveKeys) {
String receiver = convertToReceiver(systemParameter, receiveKey);
String[] strs = StringUtils.split(StringUtils.replace(receiver, ";", ","), ",");
for (String str : strs) {
if (isMail(str)) {
if (str != null) {
mailAddress.add(str);
}
} else if (isSms(str)) {
// do nothing
}
}
}
if (!mailAddress.isEmpty()) {
mail.setTo(mailAddress.toArray(new String[mailAddress.size()]));
doSendMail(mail);
}
}
use of org.springframework.mail.SimpleMailMessage in project paascloud-master by paascloud.
the class MailEntity method createSimpleMailMessage.
/**
* Create simple mail message simple mail message.
*
* @param subject the subject
* @param text the text
* @param to the to
*
* @return the simple mail message
*/
public static SimpleMailMessage createSimpleMailMessage(String subject, String text, Set<String> to) {
log.info("参数异常, 邮件信息不完整 subject={}, text={}, to={}", subject, text, to);
Preconditions.checkArgument(!PubUtils.isNull(subject, text, to), "参数异常, 邮件信息不完整");
String[] toArray = setToArray(to);
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
simpleMailMessage.setSubject(subject);
simpleMailMessage.setText(text);
simpleMailMessage.setTo(toArray);
return simpleMailMessage;
}
use of org.springframework.mail.SimpleMailMessage in project oc-explorer by devgateway.
the class SendEmailService method sendEmail.
public void sendEmail(final String subject, final String text, final String to) {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(to);
msg.setFrom("support@developmentgateway.org");
msg.setSubject(subject);
msg.setText(text);
try {
LOGGER.info("Sending email " + msg);
javaMailSenderImpl.send(msg);
} catch (MailException e) {
e.printStackTrace();
}
}
Aggregations