Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Re: solution for sending mail


Message #1 by "manish verma" <manish_verma_vk@r...> on 3 Dec 2001 13:58:09 -0000
Dear Peter,=0D=0A          Hi!=0D=0AI have gone through ur problem.It's ver
y clear that u don't have the conceot of mail servers and how do they work.
=0D=0A=0D=0AThe best way is to refer to login to any mail server provider l
ike http://www.ntl.com,http://www.scotnet.co.uk and refer to the step by st
ep instruction of how to register with the mail server in ur system.To send
 a mail through client s/w like outlook express we need to have a mail serv
er ie a server which will send mail to the desired location on our behalf.B
ut for that u should be registerd with that mail server which costs few =A3
/$/RS so if you have registerd with that service then in the configuration 
for ur outlook u need to enter the name of the mailserver.There are two mai
l servers out going and incoming mail server.Outgoing mail server uses smtp
 protocol and the incoming mail server  uses pop protocol.=0D=0AIf u r regi
stered with the service u have access to both these servers.But while cofig
uring ur account in the outlook under tool menu u need to enter ur the desi
red name by which u should be remebered by ur client and then after clickin
g in the server tab enter the incoming mail server and outgoing mail server
 name as supplied by the registering comapany.generally the name pattern is
 like this =0D=0AOutgoing mail server: smtp.ntlworld.com for ntlworld subsc
ribers=0D=0A=0D=0AIncoming mail server: pop.ntlworld.com for ntlworld subsc
ribers=0D=0A=0D=0ANormall incoming mail server name starts with pop and the
 outgoing mail server name starts with mail or smtp=0D=0Aso its this outgoi
ng mail server is to be entered while sending mails using sun.net.smtp.smtp
Client package=0D=0A=0D=0AI am giving u a small code refer to it.=0D=0A=0D
=0A=0D=0Aimport sun.net.smtp.SmtpClient;=0D=0Aimport java.io.*;=0D=0Apublic
 class Demo=0D=0A{=0D=0A	=0D=0A	=0D=0A	public static void main (String args
[] ) throws IOException=0D=0A	=0D=0A	{	System .out.println("This is the tes
t Program");=0D=0A		=0D=0A		String from=3D"manish_verma_vk@y...";=0D
=0A 		String to=3D"manish_verma_vk@r...";=0D=0A try{=0D=0A     Sm
tpClient client=3Dnew SmtpClient("smtp.ntlworld.com");	=0D=0A     client.fr
om(from);=0D=0A     client.to(to);=0D=0A     PrintStream message =3D client
.startMessage();=0D=0A     message.println("To: " + to);=0D=0A     message.
println("Subject:  Sending email from java console!");=0D=0A     message.pr
intln("This was sent from plane notepad editor!");=0D=0A     message.printl
n();=0D=0A     message.println("How do u find it!Today only i learnt to sen
d mails through java api  :-)");=0D=0A     message.println();     =0D=0A   
  message.println();=0D=0A     client.closeServer();=0D=0A  }=0D=0A  catch 
(IOException e){	=0D=0A     System.out.println("ERROR SENDING EMAIL:"+e);
=0D=0A  }=0D=0A	}=0D=0A	=0D=0A}=0D=0A =0A

  Return to Index