Java Code Examples for org.springframework.mail.javamail.MimeMessageHelper#setValidateAddresses()
The following examples show how to use
org.springframework.mail.javamail.MimeMessageHelper#setValidateAddresses() .
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 File: MailServiceImpl.java From olat with Apache License 2.0 | 6 votes |
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException { MimeMessagePreparator preparator = new MimeMessagePreparator() { public void prepare(MimeMessage mimeMessage) throws Exception { MimeMessageHelper message = new MimeMessageHelper(mimeMessage); message.setTo(mailParameters.getToMailAddress()); message.setFrom(mailParameters.getFromMailAddress()); message.setSubject(mailParameters.getSubject()); if (mailParameters.hasCcMailAddress()) { message.setCc(mailParameters.getCcMailAddress()); } if (mailParameters.hasReplyTo()) { message.setReplyTo(mailParameters.getReplyTo()); } String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties()); log.debug("*** TEST text='" + text + "'"); message.setText(text, true); message.setValidateAddresses(true); } }; this.mailSender.send(preparator); }
Example 2
Source File: MailServiceImpl.java From olat with Apache License 2.0 | 6 votes |
@Override public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException { MimeMessagePreparator preparator = new MimeMessagePreparator() { @Override public void prepare(MimeMessage mimeMessage) throws Exception { MimeMessageHelper message = new MimeMessageHelper(mimeMessage); message.setTo(mailParameters.getToMailAddress()); message.setFrom(mailParameters.getFromMailAddress()); message.setSubject(mailParameters.getSubject()); if (mailParameters.hasCcMailAddress()) { message.setCc(mailParameters.getCcMailAddress()); } if (mailParameters.hasReplyTo()) { message.setReplyTo(mailParameters.getReplyTo()); } String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties()); log.debug("*** TEST text='" + text + "'"); message.setText(text, true); message.setValidateAddresses(true); } }; this.mailSender.send(preparator); }
Example 3
Source File: MailServiceImpl.java From olat with Apache License 2.0 | 6 votes |
@Override public void sendMailWithAttachments(final TemplateWithAttachmentMailTO template) throws MailException { MimeMessagePreparator preparator = new MimeMessagePreparator() { @Override public void prepare(MimeMessage mimeMessage) throws Exception { MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true); message.addTo(template.getToMailAddress()); message.setFrom(template.getFromMailAddress()); message.setSubject(template.getSubject()); if (template.hasCcMailAddress()) { message.setCc(template.getCcMailAddress()); } if (template.hasReplyTo()) { message.setReplyTo(template.getReplyTo()); } // add attachments if any List<File> attachments = template.getAttachments(); for (File file : attachments) { message.addAttachment(file.getName(), file); } String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, template.getTemplateLocation(), template.getTemplateProperties()); message.setText(text, true); message.setValidateAddresses(true); } }; this.mailSender.send(preparator); }