hi everyone and sorry if this is a repost,
I am writing a simple SMTP client using JavaMail 1.3.2 - after the TLS handshake it stops with the server response "220 Ready to start TLS". Its working fine for non-TLS servers. Am I missing a system component (this is on linux) or is it something else.
here's the mail part of the code ;
try
{
Properties props = new Properties();
props.put("mail.smtp.host",mailSrv1);
props.put("mail.smtp.auth","true");
props.put("mail.debug", "true");
props.put("mail.smtp.starttls.enable","true");
Session mailConnection = Session.getInstance(props,null);
Message msge = new MimeMessage(mailConnection);
Address fromAddr = new InternetAddress(user,from1);
Address toAddr = new InternetAddress(to1);
// Text part of mail
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msg1);
// Attachment part of mail
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
// Create Multipart and add parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msge.setContent(mp);
msge.setFrom(fromAddr);
msge.setRecipient(Message.RecipientType.TO, toAddr);
msge.setSubject(sub1);
SMTPTransport t = (SMTPTransport)mailConnection.getTransport("smtp");
try
{
t.connect(mailSrv1, user, pass);
t.sendMessage(msge, msge.getAllRecipients());
}
finally
{
if (verbose)
{
System.out.println("Initial response = "+(rep = t.getLastServerResponse()));
}
t.close();
}
}
catch(AuthenticationFailedException afe)
{
JOptionPane.showMessageDialog(null,"Invalid UserName/Password!","Failed",JOptionPane.ERROR_MESSAGE);
error = true;
}
catch(MessagingException me)
{}
catch(UnsupportedEncodingException uee)
{}
and here is the server response (debug)
>
DEBUG: JavaMail version 1.3.2
DEBUG: java.io.FileNotFoundException: /usr/lib/java/jre/lib/javamail.providers (No such file or directory)
DEBUG: URL jar:file:/usr/lib/java/jre/lib/ext/imap.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/usr/lib/java/jre/lib/ext/imap.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/usr/lib/java/jre/lib/ext/pop3.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/usr/lib/java/jre/lib/ext/pop3.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/usr/lib/java/jre/lib/ext/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/usr/lib/java/jre/lib/ext/smtp.jar!/META-INF/javamail.providers
DEBUG: not loading resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: not loading resource: /META-INF/javamail.default.address.map
DEBUG: URL jar:file:/usr/lib/java/jre/lib/ext/smtp.jar!/META-INF/javamail.address.map
DEBUG: successfully loaded resource: jar:file:/usr/lib/java/jre/lib/ext/smtp.jar!/META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: /usr/lib/java/jre/lib/javamail.address.map (No such file or directory)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 25, isSSL false
220 mx.gmail.com ESMTP g3sm1115803wra
DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
EHLO localhost.localdomain
250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "20971520"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
Anyone can help me out here? I am using the gmai smtp server to accomplish this.
thanks