wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Java Mail problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Java Mail problem " Watch "Java Mail problem " New topic
Author

Java Mail problem

Amin Rais
Greenhorn

Joined: Aug 28, 2002
Posts: 20
Hi,
I create a simple program to send an email :
------------------------------------------------------------
Properties props = new Properties();
// Setup mail server
props.put("mail.smtp.host", hostName);
// Get session
session = Session.getDefaultInstance(props, null);
Provider[] providers = session.getProviders();
System.out.println("Provider List !!");
for (int i = 0; i < providers.length; i++)
System.out.println(providers.getProtocol() + " " +
providers.getClassName() + " " +
providers.getVendor() + " " +
providers.getVersion());
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(sender));
for (int i = 0; i < recipents.length; i++)
{
message.addRecipient(Message.RecipientType.TO, new InternetAddress (recipents));
}
message.setSubject(subject);
message.setText(content);
// Send message
Transport.send(message);
------------------------------------------------------------
In that app, some of variables are missing to simplify the codes.
Well the codes running well, and is able to send the email
if I run it under the IDE like JBuilder or any IDE..
But if I put it into JAR file then I can't execute because
of : No providers available..
Thus these lines print nothing ...
for (int i = 0; i < providers.length; i++)
System.out.println(providers.getProtocol() + " " +
providers.getClassName() + " " +
providers.getVendor() + " " +
providers.getVersion());
How can I set the provider ?
Thx...
Pete Lyons
Ranch Hand

Joined: Aug 18, 2002
Posts: 109
I think this is just because you don't have Sun's mail implementation jar file on your classpath or in the extensions directory. Change your classpath to make sure you've got the javax.mail classes as well as the com.sun.mail classes.
Matthew X. Brown
Ranch Hand

Joined: Nov 08, 2000
Posts: 165
You also need to make sure you have the activation.jar in your path
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Java Mail problem
 
Similar Threads
SHA1 digest error for javax/mail/MessagingException
FileNotFound Exception
smtp
problem of javamail within ejb
Java Mail not sending emails when using from WAN