-
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
Benjamin POCHAT
authored and
Benjamin POCHAT
committed
Jan 5, 2021
1 parent
3fd35b0
commit 22c5fe3
Showing
9 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
core/src/main/java/com/localeat/core/commons/EmailService.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.localeat.core.commons; | ||
|
||
import com.localeat.core.config.email.EmailConfig; | ||
import com.localeat.core.config.security.LocalEatRSAKey; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
|
||
import javax.mail.*; | ||
import javax.mail.internet.MimeMessage; | ||
|
||
@Controller | ||
public class EmailController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(EmailController.class); | ||
|
||
@Autowired | ||
EmailConfig emailConfig; | ||
|
||
public void sendMail(String recipient, String subject, String body) { | ||
Session session = Session.getInstance(emailConfig.getProperties(), new SimpleAuthenticator()); | ||
|
||
try { | ||
MimeMessage msg = new MimeMessage(session); | ||
msg.setFrom("[email protected]"); | ||
msg.setRecipients(Message.RecipientType.TO, recipient); | ||
msg.setSubject(subject); | ||
msg.setText(body, "UTF-8", "html"); | ||
Transport.send(msg, emailConfig.getUserName(), emailConfig.getPassword()); | ||
} catch (MessagingException mex) { | ||
LOGGER.error("send mail failed", mex); | ||
} | ||
} | ||
|
||
private class SimpleAuthenticator extends Authenticator { | ||
} | ||
} |
File renamed without changes.
64 changes: 64 additions & 0 deletions
64
core/src/main/java/com/localeat/core/config/email/EmailConfig.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.localeat.core.config.email; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.util.Properties; | ||
|
||
@ConfigurationProperties("localeat.smtp") | ||
public class EmailProperties { | ||
private boolean authentication; | ||
private boolean startTls; | ||
private String host; | ||
private String port; | ||
private String sslTrust; | ||
|
||
public boolean isAuthentication() { | ||
return authentication; | ||
} | ||
|
||
public void setAuthentication(boolean authentication) { | ||
this.authentication = authentication; | ||
} | ||
|
||
public boolean isStartTls() { | ||
return startTls; | ||
} | ||
|
||
public void setStartTls(boolean startTls) { | ||
this.startTls = startTls; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public void setHost(String host) { | ||
this.host = host; | ||
} | ||
|
||
public String getPort() { | ||
return port; | ||
} | ||
|
||
public void setPort(String port) { | ||
this.port = port; | ||
} | ||
|
||
public String getSslTrust() { | ||
return sslTrust; | ||
} | ||
|
||
public void setSslTrust(String sslTrust) { | ||
this.sslTrust = sslTrust; | ||
} | ||
|
||
public Properties getProperties() { | ||
var properties = new Properties(); | ||
properties.put("mail.smtp.auth", authentication); | ||
properties.put("mail.smtp.starttls.enable", startTls); | ||
properties.put("mail.smtp.host", host); | ||
properties.put("mail.smtp.port", port); | ||
properties.put("mail.smtp.ssl.trust", sslTrust); | ||
return properties; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/main/java/com/localeat/core/domains/actor/BreederRepository.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.domains.actor; | ||
|
||
public interface BreederRepository { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/main/java/com/localeat/core/domains/order/OrderNotificationService.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.domains.order; | ||
|
||
public class OrderNotificationService { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/main/java/com/localeat/core/domains/security/PasswordRenewalController.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.domains.security; | ||
|
||
public class PasswordRenewalController { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/test/java/com/localeat/core/commons/TestEmailController.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.commons; | ||
|
||
public class TestEmailController { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/test/java/com/localeat/core/domains/order/TestOrderNotificationService.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.domains.order; | ||
|
||
public class TestOrderNotificationService { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/test/java/com/localeat/core/domains/security/TestPasswordRenewalController.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.localeat.core.domains.security; | ||
|
||
public class TestPasswordRenewalController { | ||
} |