Java mail - SMTP server question

D

Daku

Could some Java guru please help me ? I am running JRE 1.6_16 on a
Redhat EL 2.6.9_34 machine. I am using Eclipse Galileo for the actual
development. I have sendmail running on my machine.
I have in my constructor:
sysproperties = new Properties();
session = Session.getDefaultInstance(sysproperties);
transport = session.getTransport("smtp");
transport.connect("localhost.localdomain", "root", "rootpassword");

And I get an exception as:
TestMailer constructor provider exception
javax.mail.NoSuchProviderException: smtp

I have both mailapi-1.4.3.jar and javamail-1.4.3.zip in both my
compile-time and runtime CLASSPATHs.

May I know what I need to do ? Any hints, suggestions would be
immensely valuable. thanks in advance for your help.
 
A

Albert

Le 29/12/2009 14:42, Daku a écrit :
Could some Java guru please help me ? I am running JRE 1.6_16 on a
Redhat EL 2.6.9_34 machine. I am using Eclipse Galileo for the actual
development. I have sendmail running on my machine.
I have in my constructor:
sysproperties = new Properties();
session = Session.getDefaultInstance(sysproperties);
transport = session.getTransport("smtp");
transport.connect("localhost.localdomain", "root", "rootpassword");

And I get an exception as:
TestMailer constructor provider exception
javax.mail.NoSuchProviderException: smtp

I have both mailapi-1.4.3.jar and javamail-1.4.3.zip in both my
compile-time and runtime CLASSPATHs.

May I know what I need to do ? Any hints, suggestions would be
immensely valuable. thanks in advance for your help.

As an alternative, the following code works:

Properties props = new Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.from", from);

Session session = Session.getInstance(props);

Message msg = new MimeMessage(session);
// fill msg ...

Transport.send(msg);
 
M

Martin Gregorie

I have both mailapi-1.4.3.jar and javamail-1.4.3.zip in both my
compile-time and runtime CLASSPATHs.
You also need the jats containing the provides in the class path.
In this case smtp.jar - its in the 1.4.3 ZIP archive.
 
M

Martin Gregorie

You also need the jats containing the provides in the class path. In
this case smtp.jar - its in the 1.4.3 ZIP archive.

Lets try that again, this time in English:

You also need to make sure that the jars containing the providers are in
the class path. In this case that means smtp.jar which is in the JavaMail
1.4.3 ZIP archive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top