You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Laxmilal Menaria <lm...@chambal.com> on 2009/01/30 07:32:59 UTC

Mails doesn't send with commons-email1.1

Hello every one,

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

Email email = new SimpleEmail();
String authuser = "......@gmail.com";
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("........@gmail.com", "SenderName");
email.setSubject("TestMail");
email.setMsg("This is a test mail?");
email.addTo(".............@gmail.com", "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/

Re: Mails doesn't send with commons-email1.1

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi,

after a quick look I have the following comments

+) the way set up the email looks a bit odd
"email.getMailSession().getProperties.put" versus "email.setSSL" - maybe
you double-check if using the exposed API solves the problem

+) you are using SSL so your application needs to accept the server
certificate - I think you need to import the cert into your Java
keystore or define your own trust store. When tinkering with keystores I
recommend using Portecle (http://portecle.sourceforge.net/)

Cheers,

Siegfried Goeschl

Laxmilal Menaria wrote:
> Hello every one,
>
> I have created a sample application with using commans-email 1.1 api like
> this
>
> Email email = new SimpleEmail();
> String authuser = "......@gmail.com";
> 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("........@gmail.com", "SenderName");
> email.setSubject("TestMail");
> email.setMsg("This is a test mail?");
> email.addTo(".............@gmail.com", "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.
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org