Hello every one,

I have created a sample application with using commans-email 1.1 api like
this

Email email = new SimpleEmail();
String authuser = "[email protected]";
String authpwd = "*********";
// Very Important, Don't use email.setAuthentication()
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd));
email.setDebug(true); // true if you want to debug
email.setHostName("smtp.gmail.com");

email.getMailSession().getProperties().put("mail.smtp.auth", "true");
email.getMailSession().getProperties().put("mail.debug", "true");
email.getMailSession().getProperties().put("mail.smtp.port", "465");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.port",
"465");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.fallback",
"false");
email.getMailSession().getProperties().put("mail.smtp.starttls.enable",
"true");
email.setFrom("[email protected]", "SenderName");
email.setSubject("TestMail");
email.setMsg("This is a test mail?");
email.addTo("[email protected]", "ToName");
email.send();

But When I run it its shows me the exception and mail does't send so what
can I do ?

Exception :

*org.apache.commons.mail.EmailException: Sending the email to the following
server failed : [SERVER]:[PORT]*

Please suggest me. I have tried with Cystaltech server/Gmail server. Same
crystal tech server is working with .Net application with smae setting.


-- 
Thanks,
Laxmilal menaria

http://www.bucketexplorer.com/
http://www.sdbexplorer.com/
http://www.chambal.com/

Reply via email to