add starttls and factory
This commit is contained in:
committed by
Petri Tuomola
parent
5c68e8b4a5
commit
f0d4f5e332
+8
-8
@@ -73,15 +73,15 @@ public class GmailBackedPlatformEmailService implements PlatformEmailService {
|
|||||||
props.put("mail.smtp.auth", "true");
|
props.put("mail.smtp.auth", "true");
|
||||||
props.put("mail.debug", "true");
|
props.put("mail.debug", "true");
|
||||||
|
|
||||||
try {
|
// these are the added lines
|
||||||
if (smtpCredentialsData.isUseTLS()) {
|
props.put("mail.smtp.starttls.enable", "true");
|
||||||
// Needs to disable startTLS if the port is 465 in order to send the email successfully when using the
|
// props.put("mail.smtp.ssl.enable", "true");
|
||||||
// smtp.gmail.com as the host
|
|
||||||
if (smtpCredentialsData.getPort().equals("465")) {
|
|
||||||
props.put("mail.smtp.starttls.enable", "false");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
props.put("mail.smtp.socketFactory.port", Integer.parseInt(smtpCredentialsData.getPort()));
|
||||||
|
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||||
|
props.put("mail.smtp.socketFactory.fallback", "true");
|
||||||
|
|
||||||
|
try {
|
||||||
SimpleMailMessage message = new SimpleMailMessage();
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
message.setFrom(smtpCredentialsData.getFromEmail()); // same email address used for the authentication
|
message.setFrom(smtpCredentialsData.getFromEmail()); // same email address used for the authentication
|
||||||
message.setTo(emailDetails.getAddress());
|
message.setTo(emailDetails.getAddress());
|
||||||
|
|||||||
Reference in New Issue
Block a user