Fixed email sender for custom emails

This commit is contained in:
Claudio Maggioni (maggicl) 2021-02-12 22:44:51 +01:00
parent a5bbe87e4d
commit 0ea0365c00
4 changed files with 18 additions and 4 deletions

View file

@ -46,6 +46,8 @@ public class EmailConfigurationService {
@NotNull private String registrationRedirect; @NotNull private String registrationRedirect;
@NotNull private String from;
public synchronized String getRegistrationSubject() { public synchronized String getRegistrationSubject() {
return registrationSubject; return registrationSubject;
} }
@ -109,4 +111,12 @@ public class EmailConfigurationService {
public synchronized void setRegistrationRedirect(String registrationRedirect) { public synchronized void setRegistrationRedirect(String registrationRedirect) {
this.registrationRedirect = registrationRedirect; this.registrationRedirect = registrationRedirect;
} }
public synchronized String getFrom() {
return from;
}
public synchronized void setFrom(String from) {
this.from = from;
}
} }

View file

@ -57,7 +57,7 @@ public class UserAccountController {
isRegistration isRegistration
? emailConfig.getRegistrationSubject() ? emailConfig.getRegistrationSubject()
: emailConfig.getResetPasswordSubject()); : emailConfig.getResetPasswordSubject());
mailMessage.setFrom("smarthut.sm@gmail.com"); mailMessage.setFrom(emailConfig.getFrom());
mailMessage.setText( mailMessage.setText(
(isRegistration ? emailConfig.getRegistration() : emailConfig.getResetPassword()) (isRegistration ? emailConfig.getRegistration() : emailConfig.getResetPassword())
+ " " + " "

View file

@ -13,17 +13,19 @@ spring.jpa.properties.hibernate.format_sql=true
jwt.secret=thiskeymustbeverylongorthethingcomplainssoiamjustgoingtowritehereabunchofgarbageciaomamma jwt.secret=thiskeymustbeverylongorthethingcomplainssoiamjustgoingtowritehereabunchofgarbageciaomamma
spring.mail.test-connection=true spring.mail.test-connection=true
spring.mail.host=smtp.gmail.com spring.mail.host=smtp.example.com
spring.mail.port=587 spring.mail.port=587
spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.username=smarthut.sm@gmail.com spring.mail.username=me@example.com
spring.mail.password=dcadvbagqfkwbfts spring.mail.password=example-password
spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000 spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000 spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000 spring.mail.properties.mail.smtp.writetimeout=5000
email.from=me@example.com
email.registrationSubject=Complete your SmartHut.sm registration email.registrationSubject=Complete your SmartHut.sm registration
email.registration=To confirm your registration, please click here: email.registration=To confirm your registration, please click here:
email.registrationPath=http://localhost:8080/register/confirm-account?token= email.registrationPath=http://localhost:8080/register/confirm-account?token=

View file

@ -28,6 +28,8 @@ spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000 spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000 spring.mail.properties.mail.smtp.writetimeout=5000
email.from=${MAIL_FROM}
# Registration email properties # Registration email properties
email.registrationSubject=Complete your SmartHut.sm registration email.registrationSubject=Complete your SmartHut.sm registration
email.registration=To confirm your registration, please click here: email.registration=To confirm your registration, please click here: