Sending Emails through AWS SES (#32)

This commit is contained in:
Art
2021-09-24 17:13:17 +03:00
parent 3ab2d50024
commit 61dcb2cc2a
2 changed files with 19 additions and 1 deletions

View File

@ -22,9 +22,16 @@ public class EmailService {
// Create a Simple MailMessage.
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
String carbonCopyEmail = environment.getProperty("spring.mail.username");
String fromEmail = environment.getProperty("app.email.from");
if (fromEmail == null) fromEmail = environment.getProperty("spring.mail.username");
message.setFrom(fromEmail);
String carbonCopyEmail = environment.getProperty("app.email.carbon-copy");
if (carbonCopyEmail == null) carbonCopyEmail = environment.getProperty("spring.mail.username");
log.debug("Carbon Copy Email: {}", carbonCopyEmail);
message.setCc(carbonCopyEmail);
message.setSubject(EMAIL_SUBJECT);
message.setText("Hello " + firstName + "!\n\nYour new account password is: " + password + "\n\nThe Support Team");

View File

@ -68,10 +68,21 @@ spring:
url: jdbc:mysql://localhost:3306/support_portal
username: support_portal_user
password: Supp0rt_Porta!_P@ssword
mail:
host: email-smtp.eu-north-1.amazonaws.com
port: 587
username: AKIAVW7XGDOWFHHCELIH
password: BJyWOWS1xWYR35MRCFn3BuuQ6vY+k7DRsdAvOfqDs/Fk
# we want to test (1) from localhost, (2) from S3 bucket Static Web Site, (3) from our EC2 instance
app:
email:
from: d.art.shishkin@gmail.com
carbon-copy: d.art.shishkin@gmail.com
cors:
allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net
server:
port: 5000
logging:
level:
net.shyshkin: debug