672329 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

EJB design EJB design EJB design Messages: 2 Messages: 2 Messages: 2 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Java mail - javax.mail.NoSuchProviderException: Invalid protocol

Posted by: Pyxis ... on April 28, 2005 DIGG
hi,
i try to do a sending email program (testing version) by using java.mail but some error popup.
<<coding part&gt;&gt;>
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class SendMail
{

Transport smtp_service;

public SendMail() throws Exception
{
Properties props = System.getProperties();
Session ss = Session.getDefaultInstance(props,null);
System.out.println("pass #1");
try
{
smtp_service = ss.getTransport();
}
catch (MessagingException nspe)
{
System.err.println("ERROR..No SMTP mail provider! \n"+nspe);
}
System.out.println("pass #2");
MimeMessage message = new MimeMessage(ss);
InternetAddress sender = new InternetAddress("kktang@yahoo.com","kokking");
message.setFrom(sender);
System.out.println("pass #2.5");
InternetAddress[] to_list = {new InternetAddress("kk.tang@pdx.com.my")};
message.setRecipients(Message.RecipientType.TO,to_list);
message.setSubject("Testing Emailing");
message.setHeader("keyword","HEHEE");
message.setText("Hello world...");
message.saveChanges();
System.out.println("pass #2.9");
smtp_service.send(message);
System.out.println("pass #3");


}
public static void main(String[] args)
{
try
{
SendMail xx = new SendMail();
System.out.println("Msg Send");
}
catch (Exception ee)
{
System.out.println("main error started");
System.err.println("ERROR AT MAIN\n" + ee);
System.out.println("main error terminated");
System.exit(1);
}
System.exit(0);
}
}

<<error msg popup&gt;&gt;>

pass #1
ERROR..No SMTP mail provider!
javax.mail.NoSuchProviderException: Invalid protocol: null
pass #2
pass #2.5
pass #2.9
main error started
main error terminated
ERROR AT MAIN
javax.mail.SendFailedException: Sending failed;
  nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
java.net.ConnectException: Connection refused: connect


please help... Thanks
  Message #168302 Post reply Post reply Post reply Go to top Go to top Go to top

Java mail - javax.mail.NoSuchProviderException: Invalid protocol

Posted by: Aravind K on April 28, 2005 in response to Message #168209
You should specify exchange server IP address.

Check do you have Mail provider server running on your machine?

  Message #168853 Post reply Post reply Post reply Go to top Go to top Go to top

Problem solved.. Thanks

Posted by: Pyxis ... on May 03, 2005 in response to Message #168209
Thanks a lot.. u solved my problem..

Recent active threads Recent active threads Recent active threads More More More
“Father of Java” James Gosling to keynote at TSSJS 2010
Oracle's Bold Plans for Java Bode Well
typo in faces-config to-view-id extension, but works fine?
BUY FAKE PASSPORTS OF CANADA, FAKE CANADIAN PASSPORTS FOR SALE/FAKE PASSPORTS OF USA!
BUY FAKE PASSPORTS OF UNITED KINGDOM,FAKE UK PASSPORTS FOR SALE!
BUY FAKE PASSPORTS OF CANADA, FAKE CANADIAN PASSPORTS FOR SALE!
BUY FAKE PASSPORTS OF BELGIAN,FAKE BELGIUM PASSPORTS FOR SALE!
BUY FAKE PASSPORTS OF AUSTRALIA/FAKE AUSTRALIAN PASSPORTS FOR SALE!
Milton 1.5.1 released
More active threads »
Top posters of the weekTop posters of the weekTop posters of the week
This list contains the members who have made the most posts in all forums over the last 7 days:
  1. Reza Rahman
  2. James Watson
  3. brad mcevoy
  4. Alex Besogonov
  5. Peter Monks
Hot threads Hot threads Hot threads More hot threads More hot threads More hot threads

Object pooling is now a serious performance loss

Brian Goetz continues to lift the lid and peak into the inner workings of Java in Java Urban Performance Legends. In this article he exposes the fallacy behind some of the more common performance myths found in the annals of the JVM.
(92 comments, last posted March 14, 2008)

Beyond Java

Bruce Tate, author of Better, Faster Lighter Java and Bitter EJB has come out with a new book called Beyond Java. Bruce has an epiphany about the future of software development. Does it include Java?
(770 comments, last posted September 23, 2009)

Three forms of AJAX: solid, liquid and gas.

Looks like today AJAX concept have several interpretations. We can distinguish different approaches of AJAX integration. Can they co-exist within the same application? Can we talk about layered AJAX integration?
(68 comments, last posted May 08, 2008)

Design-Time API Promises to make Java more like VB

Artima has published a short article describing the Design-Time API for JavaBeans, which was recently approved as JSR 273. This API promises to bring VB-like ease to Java development, but may face a cultural bias among Java developers who tend to think more in terms of class libraries than components.
(226 comments, last posted February 01, 2010)

Will Sun be that target of a management buyout?

There is plenty of speculation today regarding a potential buyout of Sun Microsystems by Scott McNealy and Silver Lake Partners. How would privatization of Sun affect Java?
(16 comments, last posted May 15, 2009)
More hot threads »

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy      Powered by JIVE
Site Map