package org.codenergic.theskeleton.mail.impl;

import org.codenergic.theskeleton.mail.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {
	public JavaMailSender emailSender;
	
	@Autowired
	public EmailServiceImpl(JavaMailSender emailSender) {
		this.emailSender = emailSender;
	}
	
	@Override
	@Async
	public void sendSimpleMessage(String to, String subject, String text) {
		MimeMessagePreparator messagePreparator = mimeMessage -> {
		MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage);
		messageHelper.setTo(to);
		messageHelper.setSubject(subject);
		messageHelper.setText(text);
		};
		try {
			emailSender.send(messagePreparator);
		} catch (MailException e) {}
	}
}

@@ -188,29 +188,33 @@
 rk.mail.
-MailException
+SimpleMailMessage
 ;%0Aimport
@@ -268,132 +268,8 @@
 er;%0A
-import org.springframework.mail.javamail.MimeMessageHelper;%0Aimport org.springframework.mail.javamail.MimeMessagePreparator;%0A
 impo
@@ -675,94 +675,33 @@
 %7B%0A%09%09
-MimeMessagePreparator messagePreparator = mimeMessage -%3E %7B%0A%09%09Mime
+SimpleMail
 Message
-Helper
  message
 Help
@@ -700,50 +700,33 @@
 sage
-Helper
  = new 
-MimeMessageHelper(mime
+SimpleMail
 Message
+(
 );%0A%09
@@ -729,30 +729,24 @@
 );%0A%09%09message
-Helper
 .setTo(to);%0A
@@ -750,30 +750,24 @@
 );%0A%09%09message
-Helper
 .setSubject(
@@ -789,14 +789,8 @@
 sage
-Helper
 .set
@@ -805,22 +805,8 @@
 t);%0A
-%09%09%7D;%0A%09%09try %7B%0A%09
 %09%09em
@@ -831,51 +831,10 @@
 sage
-Preparator);%0A%09%09%7D catch (MailException e) %7B%7D
+);
 %0A%09%7D%0A

Change implementation using SimpleMailMessage