mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 04:35:12 +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>
|
<version>2.4.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.mcstats</pattern>
|
<pattern>org.mcstats</pattern>
|
||||||
@ -212,13 +212,6 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</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) -->
|
<!-- GSON (required to provide 1.7.10 and below compatibility) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -12,6 +12,7 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.mail.BodyPart;
|
import javax.mail.BodyPart;
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
import javax.mail.Multipart;
|
import javax.mail.Multipart;
|
||||||
|
import javax.mail.PasswordAuthentication;
|
||||||
import javax.mail.Session;
|
import javax.mail.Session;
|
||||||
import javax.mail.Transport;
|
import javax.mail.Transport;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
@ -62,8 +63,16 @@ public class SendMailSSL {
|
|||||||
props.put("mail.smtp.host", smtp);
|
props.put("mail.smtp.host", smtp);
|
||||||
props.put("mail.smtp.auth", "true");
|
props.put("mail.smtp.auth", "true");
|
||||||
props.put("mail.smtp.port", port);
|
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);
|
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);
|
Message message = new MimeMessage(session);
|
||||||
try {
|
try {
|
||||||
@ -71,7 +80,7 @@ public class SendMailSSL {
|
|||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
message.setFrom(new InternetAddress(acc));
|
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.setSubject(subject);
|
||||||
message.setSentDate(new Date());
|
message.setSentDate(new Date());
|
||||||
BodyPart messageBodyPart = new MimeBodyPart();
|
BodyPart messageBodyPart = new MimeBodyPart();
|
||||||
@ -96,23 +105,20 @@ public class SendMailSSL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport transport = session.getTransport("smtp");
|
|
||||||
message.setContent(multipart);
|
message.setContent(multipart);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transport.connect(smtp, acc, password);
|
Transport transport = session.getTransport("smtp");
|
||||||
} catch (Exception e) {
|
transport.connect(smtp, Integer.parseInt(port), acc, password);
|
||||||
ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recovery email to " + mail);
|
|
||||||
if (file != null)
|
|
||||||
file.delete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
transport.sendMessage(message, message.getAllRecipients());
|
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)
|
if (file != null)
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
// Print the stack trace
|
// Print the stack trace
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ConsoleLogger.showError("Some error occurred while trying to send a email to " + mail);
|
ConsoleLogger.showError("Some error occurred while trying to send a email to " + mail);
|
||||||
|
Loading…
Reference in New Issue
Block a user