Best Projects

Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)

J2EE recover(Email Recoverd password)



//Recover.java
//Author: Ogbole A. Israel

//this method sends the password.
public void postMail(String smtpsrv, String recipients, String subject,String message, String from) throws MessagingException {
//TODO implement postMail
boolean debug = false;
System.out.println("got here 1");
Properties props = new Properties();
System.out.println("got here 2");
props.put("mail.smtp.host", smtpsrv);
System.out.println("got here 3");
Session session = Session.getDefaultInstance(props, null);
System.out.println("got here 4");
session.setDebug(debug);
System.out.println("got here 5");
// create a message
Message msg = new MimeMessage(session);
System.out.println("got here 6");
InternetAddress addressFrom = new InternetAddress(from);
System.out.println("got here 7");
msg.setFrom(addressFrom);
System.out.println("got here 8");
InternetAddress addressTo = new InternetAddress(recipients);
System.out.println("got here 9");
msg.setRecipient(RecipientType.TO, addressTo);
System.out.println("got here 10");
msg.setSubject(subject);
System.out.println("got here 11");
msg.setContent(message, "text/html;charset=utf-8");
System.out.println("got here 12");
Transport.send(msg);
System.out.println("got here 13");

}

//this method retrives the password. asuming the email address is primary key in the user table
public String getThePassword(String id) {
//TODO implement getThePassword
UserloginLocal userllocal = null;
try{
userllocal = userloginlhome.findByPrimaryKey(id);
}catch(Exception ex){
System.out.println("Error occured in gettting th pasword " +ex.getMessage());
}
return userllocal.getPassword();
}

No comments: