"mihir" <mi*****@indiatimes.com> wrote in message
news:3a**************************@posting.google.c om...
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.getDefaultInstance(new
java.util.Properties(), null);
Transport transport = session2.getTransport("smtp");
transport.connect /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);
MimeMessage email = new MimeMessage(session2);
email.setSubject("test");
email.setFrom(new InternetAddress("yo**@address.com", "This is me"));
email.setRecipient
(
Message.RecipientType.TO
, new InternetAddress("tohim/he*@redwood.com", "Your friend")
);
MimeBodyPart body = new MimeBodyPart();
String message = " bla bla bla "; /* The message */
email.setContent(message, "text/plain");
// Commented out for testing
transport.send(email, email.getAllRecipients());
%>
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