mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 03:05:17 +01:00
Do mail full async
This commit is contained in:
parent
017a55ae13
commit
4ca92dda59
@ -40,28 +40,38 @@ public class SendMailSSL {
|
||||
sendername = Settings.getmailSenderName;
|
||||
}
|
||||
|
||||
String port = String.valueOf(Settings.getMailPort);
|
||||
final String sender = sendername;
|
||||
final String port = String.valueOf(Settings.getMailPort);
|
||||
final String acc = Settings.getmailAccount;
|
||||
final String subject = Settings.getMailSubject;
|
||||
final String smtp = Settings.getmailSMTP;
|
||||
final String password = Settings.getmailPassword;
|
||||
final String mailText = Settings.getMailText;
|
||||
final String mail = auth.getEmail();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", Settings.getmailSMTP);
|
||||
props.put("mail.smtp.host", smtp);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.port", port);
|
||||
props.put("mail.smtp.starttls.enable", true);
|
||||
|
||||
try {
|
||||
Session session = Session.getInstance(props, null);
|
||||
|
||||
final Message message = new MimeMessage(session);
|
||||
Message message = new MimeMessage(session);
|
||||
try {
|
||||
message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
|
||||
message.setFrom(new InternetAddress(acc, sender));
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
message.setFrom(new InternetAddress(Settings.getmailAccount));
|
||||
message.setFrom(new InternetAddress(acc));
|
||||
}
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(auth.getEmail()));
|
||||
message.setSubject(Settings.getMailSubject);
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(mail));
|
||||
message.setSubject(subject);
|
||||
message.setSentDate(new Date());
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
String text = Settings.getMailText;
|
||||
messageBodyPart.setText(text);
|
||||
messageBodyPart.setText(mailText);
|
||||
|
||||
Multipart multipart = new MimeMultipart();
|
||||
|
||||
@ -71,22 +81,15 @@ public class SendMailSSL {
|
||||
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
message.setContent(multipart);
|
||||
final Transport transport = session.getTransport("smtp");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
transport.connect(Settings.getmailSMTP, Settings.getmailAccount, Settings.getmailPassword);
|
||||
Transport transport = session.getTransport("smtp");
|
||||
transport.connect(smtp, acc, password);
|
||||
transport.sendMessage(message, message.getAllRecipients());
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Some error occured while trying to send a mail to " + auth.getEmail());
|
||||
System.out.println("Some error occured while trying to send a mail to " + mail);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception e) {
|
||||
System.out.println("Some error occured while trying to send a mail to " + auth.getEmail());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user