Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sending mail with smtps fails

843830Jan 12 2005 — edited Oct 21 2005
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:
----------------------------------
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");

Why???? Please help me!!

Thank you very much in advance!
Fibo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2005
Added on Jan 12 2005
6 comments
2,507 views