Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package utils;
- import java.util.Properties;
- import javax.mail.Message;
- import javax.mail.MessagingException;
- import javax.mail.PasswordAuthentication;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- /**
- *
- * @author khlifi
- */
- public class Mailer {
- final String username = "govoyage.wemtek@gmail.com";
- final String password = "Jredpalais007";
- Properties props = new Properties();
- public void SendMailGmail(String mailTo,String newpassword){
- props.put("mail.smtp.starttls.enable", "true");
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.port", "587");
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress("govoyage.wemtek@gmail.com"));
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse(mailTo));
- message.setSubject("Réinitialisation de votre mot de passe");
- message.setText("Votre nouveau mot de passe"
- + "\n\n"
- + newpassword);
- Transport.send(message);
- System.out.println("Done");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement