Java mail - SMTP server question

Discussion in 'Java' started by Daku, Dec 29, 2009.

  1. Daku

    Daku Guest

    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.
     
    Daku, Dec 29, 2009
    #1
    1. Advertising

  2. Daku

    Albert Guest

    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);
     
    Albert, Dec 29, 2009
    #2
    1. Advertising

  3. On Tue, 29 Dec 2009 05:42:50 -0800, Daku wrote:

    > 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.


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Dec 29, 2009
    #3
  4. On Tue, 29 Dec 2009 17:12:11 +0000, Martin Gregorie wrote:

    > On Tue, 29 Dec 2009 05:42:50 -0800, Daku wrote:
    >
    >> 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.


    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.


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Dec 31, 2009
    #4
  5. Daku

    Roedy Green Guest

    On Tue, 29 Dec 2009 05:42:50 -0800 (PST), Daku <>
    wrote, quoted or indirectly quoted someone who said :

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


    do you have the jar or the directory containing the jar on the
    classpath. The second will not do. See
    http://mindprod.com/jgloss/classpath.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
     
    Roedy Green, Dec 31, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curt_C [MVP]
    Replies:
    5
    Views:
    393
    Karim
    May 19, 2004
  2. Replies:
    3
    Views:
    1,104
    Roedy Green
    Jan 24, 2006
  3. pk
    Replies:
    3
    Views:
    812
    Roedy Green
    Feb 13, 2006
  4. Alex Hunsley
    Replies:
    4
    Views:
    3,586
    Tim Williams (gmail)
    Jun 29, 2004
  5. Raaijmakers, Vincent \(GE Infrastructure\)

    RE: sending of mail (smtp) - connection refused - but smtp serveris running!

    Raaijmakers, Vincent \(GE Infrastructure\), Jun 29, 2004, in forum: Python
    Replies:
    0
    Views:
    896
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jun 29, 2004
Loading...

Share This Page