dcsimg
NoSuchProviderException sending mail with javamail to smtp server mail.libero.it
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marco_Livrieri
Posted On:   Thursday, December 2, 2010 11:44 AM

Hi, I try to send mail with mail.libero.it but I have NoSuchProviderException. I can't find wich port libero uses for ssl connection but with I can use telnet with port 25. Can you help me? Here my code that is like most of the codes I found in Internet: Properties props = new Properties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.host", "mail.libero.it"); Session sess; Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); props.put("mail.smtp.port", "25"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.soc   More>>

Hi,

I try to send mail with mail.libero.it but I have NoSuchProviderException. I can't find wich port libero uses for ssl connection but with I can use telnet with port 25.

Can you help me?

Here my code that is like most of the codes I found in Internet:


Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "mail.libero.it");

Session sess;

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", "25");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
MailAuthenticator mailAuth = new MailAuthenticator();
mailAuth.setUser("user");
mailAuth.setPassword("password");
sess = Session.getDefaultInstance(props, mailAuth);

MimeMessage mess = new MimeMessage(sess);

InternetAddress[] fromAddrs = new InternetAddress[1];
fromAddrs[0] = new InternetAddress(from);
mess.addFrom(fromAddrs);

mess.addRecipients(Message.RecipientType.TO, to);

mess.setSubject(subject);

Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
String mailContentType = "text/plain";
messageBodyPart.setDataHandler(new DataHandler(body, mailContentType));
multipart.addBodyPart(messageBodyPart);
mess.setContent(multipart);

// Sending mail
Transport.send(mess);



Thanks,
Marco

   <<Less

Re: NoSuchProviderException sending mail with javamail to smtp server mail.libero.it

Posted By:   Marco_Livrieri  
Posted On:   Thursday, December 2, 2010 02:59 PM

I have solved... printing debug of session object I have seen that was missing a class that I have found in mail.jar (to add to classpath) and after this I have delivered that my ISP doesn't support SSL (I have infostrada in Italy).

Thanks,
Marco
About | Sitemap | Contact