The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

java mail

Posted by ��T�w on June 06, 2001 at 10:27 PM

>
> iam getting smtp protocolException what is the solution


>
> import java.io.IOException;
> import java.io.PrintWriter;
> import java.io.*;
> import java.net.InetAddress;
> import sun.net.smtp.SmtpClient;

> public class EMail2
> {
> public EMail2()
> {

> try
> {
> String from ="resume@myhrpal.com";
> String to ="vincent@1800assist.com";
> String subject ="Hello From MYHRPAL";
> String body ="Welcome to MYHRPAL";

> System.out.println("From: " +from );
> System.out.println("To: " +to );
> System.out.println("Subject: " +subject);

> System.out.println("Body: " +body );

> postMail(from,to,subject,body);

> System.out.println("Thank You!!!");
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
>
> public void postMail(String fromM,String toM,String subjM,String bodyM)
> {
> PrintStream ps=null;
> SmtpClient sendmail=null;

> try
> {
> sendmail=new SmtpClient("202.184.170.177:25");

> sendmail.from(fromM);
> sendmail.to(toM);
> ps=sendmail.startMessage();

> ps.println("From:"+fromM);
> ps.println("To:"+toM);
> ps.println("Subject:"+subjM);
> ps.println("Body:"+bodyM);
> ps.flush();
> ps.close();
> sendmail.closeServer();

> System.out.println("Mail is Sent");
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
> public static void main(String[] s)
> {
> EMail2 ms =new EMail2();

> }
> }





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us