diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/EmailConfigurationService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/EmailConfigurationService.java index a87d21f..d657e35 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/EmailConfigurationService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/config/EmailConfigurationService.java @@ -46,6 +46,8 @@ public class EmailConfigurationService { @NotNull private String registrationRedirect; + @NotNull private String from; + public synchronized String getRegistrationSubject() { return registrationSubject; } @@ -109,4 +111,12 @@ public class EmailConfigurationService { public synchronized void setRegistrationRedirect(String registrationRedirect) { this.registrationRedirect = registrationRedirect; } + + public synchronized String getFrom() { + return from; + } + + public synchronized void setFrom(String from) { + this.from = from; + } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/UserAccountController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/UserAccountController.java index a0fe8d1..40d36d3 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/UserAccountController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/UserAccountController.java @@ -57,7 +57,7 @@ public class UserAccountController { isRegistration ? emailConfig.getRegistrationSubject() : emailConfig.getResetPasswordSubject()); - mailMessage.setFrom("smarthut.sm@gmail.com"); + mailMessage.setFrom(emailConfig.getFrom()); mailMessage.setText( (isRegistration ? emailConfig.getRegistration() : emailConfig.getResetPassword()) + " " diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 81e2a02..aff7fac 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -13,17 +13,19 @@ spring.jpa.properties.hibernate.format_sql=true jwt.secret=thiskeymustbeverylongorthethingcomplainssoiamjustgoingtowritehereabunchofgarbageciaomamma spring.mail.test-connection=true -spring.mail.host=smtp.gmail.com +spring.mail.host=smtp.example.com spring.mail.port=587 spring.mail.properties.mail.smtp.starttls.enable=true -spring.mail.username=smarthut.sm@gmail.com -spring.mail.password=dcadvbagqfkwbfts +spring.mail.username=me@example.com +spring.mail.password=example-password spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.connectiontimeout=5000 spring.mail.properties.mail.smtp.timeout=5000 spring.mail.properties.mail.smtp.writetimeout=5000 +email.from=me@example.com + email.registrationSubject=Complete your SmartHut.sm registration email.registration=To confirm your registration, please click here: email.registrationPath=http://localhost:8080/register/confirm-account?token= diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 570d997..9a4b70f 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -28,6 +28,8 @@ spring.mail.properties.mail.smtp.connectiontimeout=5000 spring.mail.properties.mail.smtp.timeout=5000 spring.mail.properties.mail.smtp.writetimeout=5000 +email.from=${MAIL_FROM} + # Registration email properties email.registrationSubject=Complete your SmartHut.sm registration email.registration=To confirm your registration, please click here: