smtp over ssl fails with JavaMail API

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply forum (430) 1/13/2005 2:27:48 PM

See related articles to this posting
comp.lang.java.security 1490 articles. 2 followers. Post

0 Replies
347 Views

Similar Articles

[PageSpeed] 55

Reply:

Similar Artilces:

Javamail example with POP3 and SMTP on SSL
Hello All, I am new to Javamail. I recently switched from a C++ project I was doing on Windows to Java. I have some simple E-Mail tests working, but I can't seem to figure out how to do SSL and Authentication with POP3 and SMTP using alternate ports. The mail server I am using requires this, at least for POP3. The examples that come with the Javamail SDK don't include SSL examples. Could someone out there please send or post a simple Javamail example that does at least SMTP and POP3 on SSL. Something that does authentication and uses alternate port numbers would be ice too....

Example of Javamail with SMTP and POP3 on SSL
Hello all, I am new to Javamail. I was working on a project in C++ under MS Windows (I know, boo) and decided to switch to Java. Most things are going well, except the mail part. I need to send and receive E-Mail with POP3 and SMTP running on SSL. I need to use authorization and alternate port numbers. It should be simple, but I don't seem to be able to figure it out. Could someone out there that knows a lot more than me about Javamail (that won't be hard) send or post a simple example of doing this? TIA, Adam On 2005-09-20, Charter <amesser39@hotmail.co...

Jinitiator and ssl: SSL handshake failed
For a client i need an ssl connection ; i got the certificate and implemented it. Normal ssl connections works fine, but connections with Oracle Jinitiator gives problems: SSL handshake failed error.: Opening https://[url]/forms60java/f60all_jinit.jar no proxyjavax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr at oracle.security.ssl.OracleSSLSocketImpl.startHandshake(OracleSSLSocketImpl.java) at oracle.jinitiator.protocol.https.HttpsClient.doConnect(HttpsClient.java:128) at sun.net.www.http.HttpClient.openServer(HttpClient.java:272) at sun.net.www.http.HttpClient.ope...

SSL+OE works, SSL+(Outlook or Netscape) failed
I'm running Sendmail v8.12.8, cyrus-sasl-2.1.10 and OpenSSL 0.9.7 on RedHat 9 (kernel 2.4.20 x86 machine). I have wired problem... Sendmail is receiving mail both on clear via SMTP port 25 and encrypt via SMTPS port 465, both were configured from sendmail.mc: DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl I also configured stunnel to bind port 466 (as "accept") to 25 (as "connect") in order to have a secondary encrypted port for testing the problem (which is explained below) The Problem: ...

SSL+OE works, SSL+(Outlook or Netscape) failed #2
Sendmail is receiving mail both on clear via SMTP port 25 and encrypt via SMTPS port 465, both were configured from sendmail.mc: DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl I also configured stunnel to bind port 466 (as "accept") to 25 (as "connect") in order to have a secondary encrypted port for testing the problem (which is explained below) The Problem: ------------- All tested email clients (Outlook Express v6, Mozilla v1.6, Netscape v7.1 and Outlook v2002) use the clear channel (on port 25) to se...

JavaMail API
I have just started reading about this API and found something that tells me this may not be what I need: "...users interact with Mail User Agent (MUA) type programs to read and write emails. Mail Transfer Agents (MTA) are used to handle the actual delivery." I am going to write some code where a process can trigger the need to send an email. This will all be batch - no user interaction. Is it my understanding that the JavaMail API is pretty much for user-interface? If this is not what I need, any suggestions? TIA! TC wrote: <snip> > I am going to write some code wh...

ssl with SMTP
Hi all, My company want to look into the option of using ssl with SMTP. Could anyone tell me how do we go about doing this? We intend to use one of our hub server version 5.012 for this purpose. It is a normal mail server accepting smtp connections. Can this be done? What are the other requirements needed? ...

How to set sendmail SMTP auth and SMTP SSL on Solaris 9 (x86)
Dear all, Can anybody tell me how to set sendmail SMTP auth and SMTP SSL on Solaris 9(x86). Thanks! In article <8342be4c.0307260657.1b8b2420@posting.google.com>, pcman <pcman@iloveilove.com> wrote: >Dear all, > >Can anybody tell me how to set sendmail SMTP auth and SMTP SSL on >Solaris 9(x86). Your best bet is to go to www.sendmail.org and download the source for the latest sendmail. You'll also need to get the latest version of Cyrus SASL libraries and OpenSSL. Lastly, you'll be best served re-asking your question in comp.mail.sendmail. A news post would b...

anyone knows how to program a smtp session using tcl to talk to smtp server with ssl
anyone knows how to program a smtp session using tcl to talk to smtp server with ssl? thanks. /hzw zhe@foundrynet.com (hzw) writes: > anyone knows how to program a smtp session using tcl to talk to smtp > server with ssl? thanks. Look at the tls extension and the 'smtp' module in tcllib. -- David N. Welton Consulting: http://www.dedasys.com/ Personal: http://www.dedasys.com/davidw/ Free Software: http://www.dedasys.com/freesoftware/ Apache Tcl: http://tcl.apache.org/ Hi, David: Could you tell me in more detail, for example, where can I get it and documents. tha...