Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email using SmtpClient class error???

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All
I'm trying to send emailusing smtpClient,I'm getting error says :"connection refused :no further information ".
I'm sure i'm supplying wrong arguments to from() and to() methods.
please take a look at my code and correct the argument.
thanks alot for your time.
import java.io.*;
import sun.net.smtp.SmtpClient;
import java.net.InetAddress;
import java.util.*;

public class senEmail
{
public static void main(String arg[])
{
PrintStream outMail;
SmtpClient sendmail;

try
{
sendmail = new SmtpClient(" sendmail.from("mohseif@yahoo.com");
sendmail.to("bay68@yahoo.com");

outMail = sendmail.startMessage();

outMail.println("from :tester");
outMail.flush();
outMail.close();
sendmail.closeServer();

}
catch(Exception e)
{

System.out.println(e.getMessage());
}

}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top