Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

smtp over ssl fails with JavaMail API

28 views
Skip to first unread message

Fibonaro via JavaKB.com

unread,
Jan 13, 2005, 9:27:48 AM1/13/05
to
Hi!

I?m a novice in Java and I?m going crazy...

I?m setting following properties:
-------------------------------------------
props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.host", host);
props.put("mail.smtps.user", from);
props.put("mail.smtps.port", port_str);
props.put("mail.smtps.auth", auth);
----

I?m trying to send the with:
----------------------------------
Authenticator au = new MyAuthenticator();
Session session = Session.getInstance(props, au)

Transport trans = session.getTransport();
trans.connect(host, port_i, from, pass);
trans.send(msg);
--------------

However i?m always getting the following error-message:
-----------------------------------------------------------
DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider [TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTranspor
t,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "mail.gmx.net", port 465, isSSL true 220 {mp016} GMX Mailservices ESMTP DEBUG SMTP: connected to host "mail.gmx.net", port: 465

EHLO toshm30x
250-{mp016} GMX Mailservices
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-AUTH=LOGIN CRAM-MD5 PLAIN
250-AUTH CRAM-MD5 LOGIN PLAIN
250 STARTTLS
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "AUTH=LOGIN", arg "CRAM-MD5 PLAIN"
DEBUG SMTP: Found extension "AUTH", arg "CRAM-MD5 LOGIN PLAIN"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
Y2VsYWwua2FyYWthc0BnbXguZGU=
334 UGFzc3dvcmQ6
NjA1NzY3
235 2.7.0 {mp016} Go ahead
DEBUG: getProvider() returning javax.mail.Provider [TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Su
n Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "localhost", port 25, isSSL false

--Exception handling in Mailsend.java
javax.mail.MessagingException: Could not connect to SMTP host: localhost,
port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1213)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:311)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at javax.mail.Service.connect(Service.java:86)
at com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:144)
at javax.mail.Transport.send0(Transport.java:150)
at javax.mail.Transport.send(Transport.java:80)
at Mailsend.main(Mailsend.java:108)
---------

Even when i add the following properties, i get the same error-message
above:
--------
props.put
("mail.smtps.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtps.socketFactory.fallback", "false");
props.put("mail.smtps.socketFactory.port", "465");

After smtp-auth the GMX-Mailserver aborts my ssl-request and falls back
to default properties (non-ssl on port 25). The default properties are
mail.host = localhost
mail.smtp.port = 25
as you see in the error-message above...

Why???? What am i doing wrong?? Do i have to do anything else, then to put the smtps-properties for building an ssl-conncetion??

Please help me!!

Thank you very much in advance!
Fibo

--
Message posted via http://www.javakb.com

0 new messages