#1075 Mail sender - allow to turn off TLS for port 25

This commit is contained in:
ljacqu
2017-02-26 14:12:51 +01:00
parent a2b8ca683d
commit a847deac16
5 changed files with 42 additions and 26 deletions
@@ -94,21 +94,6 @@ public class EmailService {
return sendMailSSL.sendEmail(message, htmlEmail);
}
public boolean sendTestEmail(String email) {
HtmlEmail htmlEmail;
try {
htmlEmail = sendMailSSL.initializeMail(email);
} catch (EmailException e) {
ConsoleLogger.logException("Failed to create email for sample email:", e);
return false;
}
htmlEmail.setSubject("AuthMe test email");
String message = "Hello there!<br />This is a sample email sent to you from a Minecraft server ("
+ serverName + ") via /authme debug mail. If you're seeing this, sending emails should be fine.";
return sendMailSSL.sendEmail(message, htmlEmail);
}
private File generateImage(String name, String newPass) throws IOException {
ImageGenerator gen = new ImageGenerator(newPass);
File file = new File(dataFolder, name + "_new_pass.jpg");
@@ -24,12 +24,8 @@ import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_PASSWORD;
*/
public class SendMailSSL {
private final Settings settings;
@Inject
SendMailSSL(Settings settings) {
this.settings = settings;
}
private Settings settings;
/**
* Returns whether all necessary settings are set for sending mails.
@@ -115,8 +111,10 @@ public class SendMailSSL {
}
break;
case 25:
email.setStartTLSEnabled(true);
email.setSSLCheckServerIdentity(true);
if (settings.getProperty(EmailSettings.PORT25_USE_TLS)) {
email.setStartTLSEnabled(true);
email.setSSLCheckServerIdentity(true);
}
break;
case 465:
email.setSslSmtpPort(Integer.toString(port));