当前位置: 技术问答>java相关
Could SSL be used to SMTP???
来源: 互联网 发布时间:2015-04-18
本文导语: When I am trying to use SSL to send an email, there is an error. Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host:, port: ; nested exception is: java.io.IOException: Couldn't connect using "javax.net.ssl...
When I am trying to use SSL to send an email, there is an error.
Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host:, port: ;
nested exception is:
java.io.IOException: Couldn't connect using "javax.net.ssl.SSLSocketFactory" socket factor
to host, port: , ; Exception: java.lang.reflect.InvocationTargetException
The proprties I use are setup like this:
String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
props.setProperty("mail.smtp.host", MailSettings.MAIL_PROXY);
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", Integer.toString(MailSettings.PORT) );
props.setProperty("mail.smtp.socketFactory.port", Integer.toString(MailSettings.PORT));
When I change the fallback it is OK, I assume this is because it reverts to a non-secure mode. Which means a notmal smtp transfer. Although the message is (will be) encrypted I still want to use SSL to send the email..
Could this be the result of using the wrong port on the mailserver??
If anyone has managed to send secure email, plese respond, I am getting a bit short of ideas..
Thanks
Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host:, port: ;
nested exception is:
java.io.IOException: Couldn't connect using "javax.net.ssl.SSLSocketFactory" socket factor
to host, port: , ; Exception: java.lang.reflect.InvocationTargetException
The proprties I use are setup like this:
String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
props.setProperty("mail.smtp.host", MailSettings.MAIL_PROXY);
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", Integer.toString(MailSettings.PORT) );
props.setProperty("mail.smtp.socketFactory.port", Integer.toString(MailSettings.PORT));
When I change the fallback it is OK, I assume this is because it reverts to a non-secure mode. Which means a notmal smtp transfer. Although the message is (will be) encrypted I still want to use SSL to send the email..
Could this be the result of using the wrong port on the mailserver??
If anyone has managed to send secure email, plese respond, I am getting a bit short of ideas..
Thanks
|
没试过,不过你用outlook试一下就知道你用的
smtp server是否支持ssl了,outlook里的账户属性
里面设置smtp server的时候,有一项是给你选择
是否用ssl来传送的,通常smtp server会开两个端口,
一个是用来给普通方式的传送,一个是用ssl方式
传送,如果你要确认的话,最好联系一下你的smtp server
供应商,看他们是否支持ssl传送
smtp server是否支持ssl了,outlook里的账户属性
里面设置smtp server的时候,有一项是给你选择
是否用ssl来传送的,通常smtp server会开两个端口,
一个是用来给普通方式的传送,一个是用ssl方式
传送,如果你要确认的话,最好联系一下你的smtp server
供应商,看他们是否支持ssl传送