-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marc Gorzala
committed
Dec 28, 2023
1 parent
2c09423
commit f4894c9
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/net/dancier/kikeriki/adapter/out/mail/MailSenderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
package net.dancier.kikeriki.adapter.out.mail; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.JavaMailSenderImpl; | ||
|
||
import java.util.Properties; | ||
|
||
@Configuration | ||
public class MailSenderConfiguration { | ||
|
||
@Bean | ||
@Profile({"dev"}) | ||
public JavaMailSender getJavaMailSender() { | ||
JavaMailSender javaMailSender = new DumpingMailSender(); | ||
return javaMailSender; | ||
} | ||
|
||
@Profile("staging") | ||
public JavaMailSender getRealSender( | ||
@Value("${app.mail.host}") String hostname, | ||
@Value("${app.mail.port}") String port, | ||
@Value("${app.mail.user}") String user, | ||
@Value("${app.mail.pass}") String pass | ||
) { | ||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); | ||
javaMailSender.setHost(hostname); | ||
javaMailSender.setPort(Integer.valueOf(port)); | ||
|
||
javaMailSender.setUsername(user); | ||
javaMailSender.setPassword(pass); | ||
|
||
Properties props = javaMailSender.getJavaMailProperties(); | ||
props.put("mail.smtp.ssl.enable", "true"); | ||
props.put("mail.debug", "true"); | ||
|
||
return javaMailSender; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
spring: | ||
profiles: | ||
active: dev | ||
datasource: | ||
url: jdbc:postgresql://localhost:5432/kikeriki | ||
username: kikeriki | ||
|