Add switch between SSL and StartTLS security on email
This commit is contained in:
parent
5d21d1bb87
commit
61735b4941
@ -3,6 +3,7 @@ package fr.xephi.authme;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
import org.apache.commons.mail.DefaultAuthenticator;
|
||||||
import org.apache.commons.mail.EmailException;
|
import org.apache.commons.mail.EmailException;
|
||||||
import org.apache.commons.mail.HtmlEmail;
|
import org.apache.commons.mail.HtmlEmail;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -64,9 +65,21 @@ public class SendMailSSL {
|
|||||||
email.addTo(mail);
|
email.addTo(mail);
|
||||||
email.setFrom(acc, sender);
|
email.setFrom(acc, sender);
|
||||||
email.setSubject(subject);
|
email.setSubject(subject);
|
||||||
email.setAuthentication(acc, password);
|
if (acc != null && !acc.isEmpty() && password != null && !password.isEmpty())
|
||||||
email.setStartTLSEnabled(true);
|
email.setAuthenticator(new DefaultAuthenticator(acc, password));
|
||||||
email.setStartTLSRequired(true);
|
switch (port) {
|
||||||
|
case 587:
|
||||||
|
case 25:
|
||||||
|
email.setStartTLSEnabled(true);
|
||||||
|
break;
|
||||||
|
case 465:
|
||||||
|
email.setSSLOnConnect(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
email.setStartTLSEnabled(true);
|
||||||
|
email.setSSLOnConnect(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
email.setSSLCheckServerIdentity(true);
|
email.setSSLCheckServerIdentity(true);
|
||||||
String content = mailText;
|
String content = mailText;
|
||||||
// Generate an image ?
|
// Generate an image ?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user