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 1493 articles. 2 followers. Post

0 Replies
434 Views

Similar Articles

[PageSpeed] 44


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

"Failed set trust point in ssl context" when using SSL communication
hello, I am now developing a client and server system which needs SSL support. As this system is developed by microsoft j++, so I can only use the SSL package which support jdk1.1. Now I only found that oracle has a solution for SSL which support jkd1.1(SUN's jsse package only support from jdk1.2). It described the method and sample code in Oracle Advanced Security Administrator's Guide Release 2 (9.2) (http://web.urz.uni-heidelberg.de/UnixCluster/Hinweise/Hilfe/Anwendung/Db/oracle.doc.816/network.816/a76932/appf_ora.htm) I tried it, but met "Failed set trust point in ssl conte...

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

A problem with GSS-API (kdc = SEAM by SUN): GSSException Failure unspecified at GSS-API level (Mechanism level: Integrity check on decrypted field failed (31))
Hi doc!!!!: I am running the Sample with tutorial "Use of JAAS Login Utility and Java GSS-API for Secure Messages without JAAS programming" KDC is a SEAM in Solaris 9 JDK 1.5 The Code are SampleClient.java y SampleServer.java without relevant modifications If anyone has any ideas I'm all ears. Don Alex SERVER: Waiting for incoming connection... Got connection from client /157.253.50.59 Will read input token of size 517 for processing by acceptSecContext Debug is true storeKey true useTicketCache false useKeyTab false doNotPrompt false ticketCache is null KeyTab is null...

Net::SMTP fails
Gang, I am trying to use Net::SMTP to send email from a computer and it fails to send (debug info below). I can take this same script and put it on another computer and it works just fine. That would tell me some piece of software isn't installed on the non-working computer, but I have no idea as to what it may be. I have made sure the files are the same on both computers that are listed in the "use" statements at the top of the Net::SMTP module. I am using Debian 3.1 on the one that works and 4.0 on the one that doesn't work. Any help would greatly be appreciated....

SSL for SMTP tests ?
A friend is having problems setting his windows/PDA to communicate with an SMTP server. Since his ISP blocks outbound port 25, he needs to use SSL to communicate with the remote SMTP server (where, once in, he authenticates with username/password). He has no tools to debug this. Is it possible to do the moral equivalent on VMS: TELNET/SSL/PORT=25 smtp.chocolate.com ?? I have openssl installed on my machine. I'd like to be able to connect to his smtp server via SSL to ensure that the SSL service actually works and can bridge to the SMTP service on that server. Once I get the SMTP welco...

Problems with SSL and SMTP
Hello everyone. I have tested the below piece of code with Tcl8.4 & Tcl8.5. I am running this on a FreeBSD machine, with tcllib 1.9 and tcllib 1.10. I have tls 1.5 installed (and working). Please, note that I am connecting to port 465, which is SMTP with SSL. package require mime package require smtp set token [mime::initialize -canonical text/plain -string "This is the body"] mime::setheader $token Subject "Test e-mail" smtp::sendmessage $token \ -servers myserver \ -ports 465 \ -debug 1 \ ...

LOGIN fails with SSL
I am trying to LOGIN & retrieve data using SSL A100 LOGIN "abc" "agc" //fails with error "NO Clear text passwords //have been disabled for this protocol" I am using .net 2.0 class SSlStream for SSL communication. Here is the code snippet.... SSlStream m_objSllStream; m_objSllStream.AuthenticateAsClient() if(m_objSllStream.IsEncrypted == true) { m_objSllStream.Write("A100 LOGIN "abc" "agc""); //This is LOGIN command to IMAP with //clear text Username & Password. //LOGIN command fa...

SSL Negotiation fails
My ISP, SBC, recently sent me instructions for new email settings. They said that I had to require an encrypted connection and use SMTP port 465. After reviewing Eudora's documentation, I concluded that I could get that result by setting "Secure Sockets when Sending" to "Required, Alternate Port." Now I get an error message the first time I try to send email after starting Eudora. The message reads SBC Main, Connecting to the Mail Server..., SSL Negotiation Failed: The connection with the server has been lost. Cause: (5) SBC Main, Connecting to the Mail ...

ssl negotiation failed.
halo i use 6.02 i add certyficat and also install but still have problem with sending email via ssla and smtp 995port. can you help me ? R, -- : GG: 328.28.00 : email: studio[|,a,t,|]post,pl U�ytkownik 328.28.00 napisa�: [...] error is: SSL Negotiation Failed Cause: (-6994) R, ...

ssl popen API
Hi, Can anyone tell me how to invoke ssl popen API from ACE? I m looking for some example and guideline for it. Thanks Sam ...

SSL Negotiation Failed
Hi, All. I need some help. I'm running Windows ME (I know, I know . . . you're sorry to hear that), and just used Windows Update to load some security patches. Now, when I attempt to access my email in Eudora (Version 6.0.0.10), I get the following message: <Dominant>, Logging into POP Server, CAPA [06:47:34 PM SSL Negotiation Failed: Certificate Error: Cert Chain not trusted. Try adding this certificate to your certificate database for SSL to succeed. Certificate bad: Host name does match host name in certificate Cause: [-6995] Does anyone have a...

NtCreateFile API failed
When trying to open CdRom0 using NtCreateFile the return value is 0. (Could not acquire handle value) Cannot determine the reason behind the return failure. Code is a console-based program developed under Windows XP Service Pack 2. Please advise on possible solutions. Thank you. #include <windows.h> #include <stdio.h> #define NTSTATUS LONG #define OBJ_CASE_INSENSITIVE 0x00000040L #define OBJ_KERNEL_HANDLE 0x00000200L // Desire Mode #define DESIRE_ACCESS ( SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA | STANDARD_RIGHTS_READ | STANDARD_RIGH...

[Fwd: Re: A problem with GSS-API (kdc = RH A.S. R3) GSSException: Failure unspecified at GSS-API level (Mechanism level: Checksum failed)
This is a multi-part message in MIME format. --Boundary_(ID_ZPOPgV2Eyj2zKWDAp18jPg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT --Boundary_(ID_ZPOPgV2Eyj2zKWDAp18jPg) Content-type: message/rfc822; name="failed) - GSSException: Securitycontext init/accept not yet called or context deleted (Mechanism level: Wrapcalled in invalid st" Date: Fri, 26 Nov 2004 13:35:56 -0800 From: Seema Malkani <Seema.Malkani@sun.com> Subject: Re: A problem with GSS-API (kdc = RH A.S. R3) GSSException: Failure unspecified at GSS-API level (Mechanism level: Checks...

A problem with GSS-API (kdc = RH A.S. R3) GSSException: Failure unspecified at GSS-API level (Mechanism level: Checksum failed)
Hi doc!!!!: I am running the Sample with tutorial "Use of JAAS Login Utility and Java GSS-API for Secure Messages without JAAS programming" KDC is a Red Hat Linux AS release 3 JDK 1.5 The Code are SampleClient.java y SampleServer.java without relevant modifications If anyone has any ideas I'm all ears. Don Alex SERVER: Debug is true storeKey true useTicketCache false useKeyTab false doNotPrompt false ticketCache is null KeyTab is null refreshKrb5Config is false principal is mquiroga/pele.uniandes.edu.co@UNIANDES.EDU.CO tryFirstPass is false useFirstPass is false storeP...

Re: SSL for SMTP tests ?
From: JF Mezei <jfmezei.spamnot@teksavvy.com> > A friend is having problems setting his windows/PDA to communicate with > an SMTP server. > > Since his ISP blocks outbound port 25, he needs to use SSL to > communicate with the remote SMTP server (where, once in, he > authenticates with username/password). I'm glad to hear that _someone's_ ISP blocks port 25. > He has no tools to debug this. > > Is it possible to do the moral equivalent on VMS: > > TELNET/SSL/PORT=25 smtp.chocolate.com ?? > > I have openssl installed on my machine. ...

JAVAMAIL SMTP error 421
Hi all, I've been looking at this problem for a while, browsing all possible resources for a possible explanation but no way. My problem is the following : I've got a JAVA application listening to messages falling on a MQSeries queue. The message falling on the queue contains all required information to compose a mail intended for some recipients. The application is connected to a mail server and is supposed to send the mail. In our development environment everything is fine and works properly. We are using Exchange server. I made several tests with some 3000 messages falling on th...