mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 10:45:23 +01:00
Fix Mail Recovery
This commit is contained in:
parent
f5c4a713ef
commit
6bff45f0ed
9
pom.xml
9
pom.xml
@ -87,7 +87,7 @@
|
||||
<version>2.4.2</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
@ -212,13 +212,6 @@
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- GSON (required to provide 1.7.10 and below compatibility) -->
|
||||
<dependency>
|
||||
|
@ -12,6 +12,7 @@ import javax.imageio.ImageIO;
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
@ -62,8 +63,16 @@ public class SendMailSSL {
|
||||
props.put("mail.smtp.host", smtp);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.port", port);
|
||||
props.put("mail.smtp.socketFactory.port", port);
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
props.put("mail.smtp.starttls.enable", true);
|
||||
Session session = Session.getInstance(props, null);
|
||||
props.put("mail.smtp.socketFactory.fallback", false);
|
||||
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
|
||||
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(acc, password);
|
||||
}
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
try {
|
||||
@ -71,7 +80,7 @@ public class SendMailSSL {
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
message.setFrom(new InternetAddress(acc));
|
||||
}
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(mail));
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(mail));
|
||||
message.setSubject(subject);
|
||||
message.setSentDate(new Date());
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
@ -96,23 +105,20 @@ public class SendMailSSL {
|
||||
}
|
||||
}
|
||||
|
||||
Transport transport = session.getTransport("smtp");
|
||||
message.setContent(multipart);
|
||||
|
||||
try {
|
||||
transport.connect(smtp, acc, password);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recovery email to " + mail);
|
||||
if (file != null)
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
Transport transport = session.getTransport("smtp");
|
||||
transport.connect(smtp, Integer.parseInt(port), acc, password);
|
||||
transport.sendMessage(message, message.getAllRecipients());
|
||||
|
||||
transport.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Cannot send email to " + mail + ", an error occured!");
|
||||
}
|
||||
if (file != null)
|
||||
file.delete();
|
||||
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Print the stack trace
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Some error occurred while trying to send a email to " + mail);
|
||||
|
Loading…
Reference in New Issue
Block a user