Fix attachment

This commit is contained in:
Xephi59 2015-11-11 01:49:15 +01:00
parent a9a057c278
commit 46d39c7864
2 changed files with 5 additions and 3 deletions

View File

@ -53,11 +53,11 @@ public class SendMailSSL {
email.addTo(mail);
email.setFrom(acc, sender);
email.setSubject(subject);
email.setHtmlMsg(mailText);
email.setAuthentication(acc, password);
email.setStartTLSEnabled(true);
email.setStartTLSRequired(true);
email.setSSLCheckServerIdentity(true);
String content = mailText;
// Generate an image ?
File file = null;
if (Settings.generateImage) {
@ -66,11 +66,13 @@ public class SendMailSSL {
file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg");
ImageIO.write(gen.generateImage(), "jpg", file);
DataSource source = new FileDataSource(file);
email.embed(source, auth.getNickname() + "_new_pass.jpg");
String tag = email.embed(source, auth.getNickname() + "_new_pass.jpg");
content = content.replace("<image>", "<img src=\"cid:" + tag + "\">");
} catch (Exception e) {
ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail);
}
}
email.setHtmlMsg(content);
try {
email.send();
} catch (Exception e) {

View File

@ -340,7 +340,7 @@ Email:
# Email subject of password get
mailSubject: 'Your new AuthMe Password'
# Email text here
mailText: 'Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword'
mailText: 'Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><image><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword'
# Like maxRegPerIp but with email
maxRegPerEmail: 1
# Recall players to add an email ?