Saturday, 15 January 2011

java - how to do email verification by sending the mail in jsp -



java - how to do email verification by sending the mail in jsp -

i having registration form.after submitting goes jsp page gets info of form , stores in database.now want send email user id has given confirmation.i don't have thought it. please me code it. registration form action , submit code.

<form action="signupdata.jsp" method="post"> <input type="submit" onclick="" value="submit">

this on signupdata.jsp save info in database.

int i=st.executeupdate("insert userdetails(firstname,lastname,email,password,cpassword,category) values('"+fname+"','"+lname+"','"+emal+"','"+pwd+"','"+cpwd+"','"+ctgry+"')");

now want send email of confirmation user's email id of websites provides.

write below code in firtpage.jsp

<form action="signupdata.jsp" method="post"> please come in email : <input type="text" name="email"> <input type="submit" onclick="" value="submit"> </form>

write below code in signupdata.jsp

// recipient's email id needs mentioned. string = request.getparameter("email"); // sender's email id needs mentioned string = "sender_email"; // assuming sending email localhost string host = "your_email_host"; // scheme properties properties properties = system.getproperties(); // setup mail service server properties.setproperty("mail.smtp.host", host); // default session object. session session = session.getdefaultinstance(properties); try{ // create default mimemessage object. mimemessage message = new mimemessage(session); // set from: header field of header. message.setfrom(new internetaddress(from)); // set to: header field of header. message.addrecipient(message.recipienttype.to, new internetaddress(to)); // set subject: header field message.setsubject("suvject_line"); // set actual message message.settext("your message goes here"); // send message transport.send(message); system.out.println("sent message successfully...."); }catch (messagingexception mex) { mex.printstacktrace(); } }

java registration

No comments:

Post a Comment