65. Email session (#7)

This commit is contained in:
Art
2021-09-08 17:41:12 +03:00
parent a27f59246e
commit dad5fedc9e
2 changed files with 30 additions and 0 deletions

View File

@ -66,6 +66,11 @@
<version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -0,0 +1,25 @@
package net.shyshkin.study.fullstack.supportportal.backend.service;
import org.springframework.stereotype.Service;
import javax.mail.Session;
import java.util.Properties;
import static net.shyshkin.study.fullstack.supportportal.backend.constant.EmailConstant.*;
@Service
public class EmailService {
private Session getEmailSession() {
Properties properties = System.getProperties();
properties.put(SMTP_HOST, GMAIL_SMTP_SERVER);
properties.put(SMTP_AUTH, true);
properties.put(SMTP_PORT, DEFAULT_PORT);
properties.put(SMTP_STARTTLS_ENABLE, true);
properties.put(SMTP_STARTTLS_REQUIRED, true);
return Session.getInstance(properties);
}
}