Minor - small addition to SendMailSSL refactor
This commit is contained in:
parent
02c366637e
commit
fc3f503ac8
@ -32,7 +32,6 @@ public class SendMailSSL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void main(final PlayerAuth auth, final String newPass) {
|
public void main(final PlayerAuth auth, final String newPass) {
|
||||||
final int port = Settings.getMailPort;
|
|
||||||
final String mailText = replaceMailTags(Settings.getMailText, plugin, auth, newPass);
|
final String mailText = replaceMailTags(Settings.getMailText, plugin, auth, newPass);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@ -42,7 +41,6 @@ public class SendMailSSL {
|
|||||||
HtmlEmail email;
|
HtmlEmail email;
|
||||||
try {
|
try {
|
||||||
email = initializeMail(auth);
|
email = initializeMail(auth);
|
||||||
setPropertiesForPort(port, email);
|
|
||||||
} catch (EmailException e) {
|
} catch (EmailException e) {
|
||||||
ConsoleLogger.showError("Failed to create email with the given settings: "
|
ConsoleLogger.showError("Failed to create email with the given settings: "
|
||||||
+ StringUtils.formatException(e));
|
+ StringUtils.formatException(e));
|
||||||
@ -87,16 +85,17 @@ public class SendMailSSL {
|
|||||||
|
|
||||||
private static HtmlEmail initializeMail(PlayerAuth auth) throws EmailException {
|
private static HtmlEmail initializeMail(PlayerAuth auth) throws EmailException {
|
||||||
String senderName;
|
String senderName;
|
||||||
if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) {
|
if (StringUtils.isEmpty(Settings.getmailSenderName)) {
|
||||||
senderName = Settings.getmailAccount;
|
senderName = Settings.getmailAccount;
|
||||||
} else {
|
} else {
|
||||||
senderName = Settings.getmailSenderName;
|
senderName = Settings.getmailSenderName;
|
||||||
}
|
}
|
||||||
String senderMail = Settings.getmailAccount;
|
String senderMail = Settings.getmailAccount;
|
||||||
String mailPassword = Settings.getmailPassword;
|
String mailPassword = Settings.getmailPassword;
|
||||||
|
int port = Settings.getMailPort;
|
||||||
|
|
||||||
HtmlEmail email = new HtmlEmail();
|
HtmlEmail email = new HtmlEmail();
|
||||||
email.setSmtpPort(Settings.getMailPort);
|
email.setSmtpPort(port);
|
||||||
email.setHostName(Settings.getmailSMTP);
|
email.setHostName(Settings.getmailSMTP);
|
||||||
email.addTo(auth.getEmail());
|
email.addTo(auth.getEmail());
|
||||||
email.setFrom(senderMail, senderName);
|
email.setFrom(senderMail, senderName);
|
||||||
@ -105,6 +104,8 @@ public class SendMailSSL {
|
|||||||
String password = !Settings.emailOauth2Token.isEmpty() ? "" : mailPassword;
|
String password = !Settings.emailOauth2Token.isEmpty() ? "" : mailPassword;
|
||||||
email.setAuthenticator(new DefaultAuthenticator(senderMail, password));
|
email.setAuthenticator(new DefaultAuthenticator(senderMail, password));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPropertiesForPort(email, port);
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ public class SendMailSSL {
|
|||||||
.replace("<generatedpass />", newPass);
|
.replace("<generatedpass />", newPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPropertiesForPort(int port, HtmlEmail email) throws EmailException {
|
private static void setPropertiesForPort(HtmlEmail email, int port) throws EmailException {
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case 587:
|
case 587:
|
||||||
email.setStartTLSEnabled(true);
|
email.setStartTLSEnabled(true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user