Vishal_donth gave this response on 10/18/2000:
// These are the pakages to be imported from
// Java mail
// The Java mail package either be dowloaded
// Seperately
// Or else is available in the j2sdkee1.2
// (Java Enterprise Edition)
Import javax. Mail .*;
Import javax. Mail. Internet .*;
Import java. util .*;
// This function can be used to send the mail
// With the parameters given to it
// U have to specify the SMTP server through
// Which u have to send the mail
// Since I was trying with a homenetmail
// Account I directly sent the mail its server
// For sending this mail u need a mail server
// Which lets u to relay the messages
// Try this thing for sending to
// Www.homenetmail.com account because it lets
// U send
// Mails to the accounts like example try
// Sending it to a "abc@homenetmail.com"
// Account. Create the mail account in HomeNet
// Mail first. If u get any other server which
// Supports relaying u can try this on that
// Also.
// Use this function in ur servlet to send
// Mail by calling the function with
// Parameters
Public void Sendmail (string toaddr, string subject, string body, string fromaddr) throws RemoteException {
try {
properties props = new properties ();
props. put ("mail. SMTP. host "," mail.homenetmail.com ");
// here we specify the SMTP server through
// which the mail shocould be delivered
session = session. getdefaultinstance (props, null);
message MSG = new mimemessage (session);
MSG. setfrom (New internetaddress (fromaddr);
// specify the FROM address
internetaddress [] TOS = internetaddress. parse (toaddr);
// specify the to address
MSG. setrecipients (message. recipienttype. to, TOS);
MSG. setsubject (subject);
// specify the subject
MSG. settext (body);
// specify the body
transport. send (MSG);
system. out. println ("message is sent");
}< br> catch (exception e) {
system. out. println (E);
}< BR >}
// U have to run this function on a computer
// which is directly connected
// to Internet but not through a
/Proxy ...... or else use a proxy which
// supports SMTP