diff --git a/src/utilities/Mail.java b/src/utilities/Mail.java index 33c02b0..3e9499a 100644 --- a/src/utilities/Mail.java +++ b/src/utilities/Mail.java @@ -176,6 +176,41 @@ protected PasswordAuthentication getPasswordAuthentication(){ mex.printStackTrace(); } } + + public void sendTemporaryPassword(String password) { + String subject = "Your temporary {Application name} password"; + String messege = "" + + "" + + "" + + "

Your pasword has been reset. To login in, please use the password "+password+"


" + + "

You will be prompted to set a new password. If you didn't initiate this, sorry. Someone's probably messing with you.

" + + "" + + "" + + ""; + Properties properties = System.getProperties(); + properties = setProp(sender, client.getEmail()); + Session session = Session.getInstance(properties, new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication(){ + return new PasswordAuthentication(sender, password); + } + }); + + try { + Address address = new InternetAddress(client.getEmail()); + MimeMessage message = new MimeMessage(session); + message.setFrom(address); + message.addRecipient(Message.RecipientType.TO, address); + message.setSubject(subject); + message.setText(messege,"utf-8","html"); + message.saveChanges(); + Transport.send(message); + System.out.println("Sent message successfully...."); + + } catch (Exception mex) { + mex.printStackTrace(); + } + } + private Properties setProp(String email, String targetEmail) { Properties props = null; try {