From 9223a375301fb49076459c4201be11a9b59cce9c Mon Sep 17 00:00:00 2001 From: Chinmay Chaudhari <33475051+chinmay9194@users.noreply.github.com> Date: Sat, 3 Oct 2020 22:04:21 +0530 Subject: [PATCH] Changes for STMP Connection in application.properties (#15) * Changes for STMP Connection in application.properties * Removed EMailConfig File and Removed COmments from EmailService * Changed Readme file for SMPT Configuration --- Readme.md | 2 +- .../java/me/anant/PMS/config/EmailConfig.java | 29 ----------- .../me/anant/PMS/service/EmailService.java | 52 ++++++++----------- src/main/resources/application.properties | 17 ++++++ 4 files changed, 40 insertions(+), 60 deletions(-) delete mode 100644 src/main/java/me/anant/PMS/config/EmailConfig.java diff --git a/Readme.md b/Readme.md index 0e398f1..43de72d 100644 --- a/Readme.md +++ b/Readme.md @@ -20,7 +20,7 @@ It is a marketplace where customer can place order and Admin can manage inventor - Maven ## Configuration -Change the SMTP details in "EmailConfig" +Change the SMTP details in "application.properties" ## Login Details diff --git a/src/main/java/me/anant/PMS/config/EmailConfig.java b/src/main/java/me/anant/PMS/config/EmailConfig.java deleted file mode 100644 index 4df224e..0000000 --- a/src/main/java/me/anant/PMS/config/EmailConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.anant.PMS.config; - -import java.util.Properties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.JavaMailSenderImpl; - -@Configuration -public class EmailConfig { - @Bean - public JavaMailSender getJavaMailSender() - { - JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); - mailSender.setHost("smtp.mailtrap.io"); - mailSender.setPort(2525); - - mailSender.setUsername("53b095fe63e8b6"); - mailSender.setPassword("c87dc71a300727"); - - Properties props = mailSender.getJavaMailProperties(); - props.put("mail.transport.protocol", "smtp"); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.starttls.enable", "true"); - props.put("mail.debug", "true"); - - return mailSender; - } -} diff --git a/src/main/java/me/anant/PMS/service/EmailService.java b/src/main/java/me/anant/PMS/service/EmailService.java index c2399cc..334c216 100644 --- a/src/main/java/me/anant/PMS/service/EmailService.java +++ b/src/main/java/me/anant/PMS/service/EmailService.java @@ -8,40 +8,32 @@ import org.springframework.mail.javamail.MimeMessagePreparator; import org.springframework.stereotype.Service; -import me.anant.PMS.config.EmailConfig; - @Service public class EmailService { + @Autowired - EmailConfig emailConfig; - + private JavaMailSender javaMailSender; + public void send(String to, String subject, String body) { - String template = "\r\n" + - "\r\n" + - "
\r\n" + - "" - + "" - + "" - + "" - + body - + "