"mihir" <mi*****@indiat imes.com> wrote in message
news:3a******** *************** ***@posting.goo gle.com...
does any one have a clue as to how to send a mail via jsp/servlets.
Oui...
http://java.sun.com/products/javamail/
Download the mail api and here's a little code example of how to do it....
<%
Session session2 = Session.getDefa ultInstance(new
java.util.Prope rties(), null);
Transport transport = session2.getTra nsport("smtp");
transport.conne ct /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);
MimeMessage email = new MimeMessage(ses sion2);
email.setSubjec t("test");
email.setFrom(n ew InternetAddress ("yo**@address. com", "This is me"));
email.setRecipi ent
(
Message.Recipie ntType.TO
, new InternetAddress ("tohim/he*@redwood.com ", "Your friend")
);
MimeBodyPart body = new MimeBodyPart();
String message = " bla bla bla "; /* The message */
email.setConten t(message, "text/plain");
// Commented out for testing
transport.send( email, email.getAllRec ipients());
%>
To be honoust... I just typed this in. There might be some mistakes. You can
either use Transport.send (which uses for example default mail on unix) or
connect to a server (which I do in the example) and the use the transport
object to send the mail instread of the static call.
Adieu,
Rein