当前位置: 技术问答>java相关
急救,救救我的Javamail发布了邮件!
来源: 互联网 发布时间:2015-02-18
本文导语: javamail 发送邮件时保错“NosuchProviderException rf(822)”怎么解决,sun网站说明: Q: My servlet can find the JavaMail classes, but JavaMail complains that it can't find a service provider for "smtp" or "imap" or address type "rfc822". A...
javamail 发送邮件时保错“NosuchProviderException rf(822)”怎么解决,sun网站说明:
Q: My servlet can find the JavaMail classes, but JavaMail complains that it can't find a service provider for "smtp" or "imap" or address type "rfc822".
A: Usually this is because JavaMail can't access the configuration files in mail.jar, possibly because of a security permission problem; see this item for more details. Also, make sure that you haven't extracted the mail.jar contents; you should include the unmodified mail.jar file in the server's CLASSPATH.
To allow an application to use JavaMail under a JDK 1.2 SecurityManager, the application, JavaMail, and JAF will need permissions such as the following (be sure to replace the host and path names with appropriate values); add these to the security policy file used by the application:
grant {
// following two permissions allow access to default config files
permission java.io.FilePermission "/path/to/mail.jar", "read";
permission java.io.FilePermission
"/path/to/activation.jar", "read";
// following to use SMTP
permission java.net.SocketPermission
"SMTPHOST:25", "connect,resolve";
// following to use IMAP
permission java.net.SocketPermission
"IMAPHOST:143", "connect,resolve";
// following to use POP3
permission java.net.SocketPermission
"POP3HOST:110", "connect,resolve";
// following also to use POP3 in pre-JavaMail 1.2
permission java.io.FilePermission "/path/to/pop3.jar", "read";
// following needed if System.getProperties() is used
permission java.util.PropertyPermission "*", "read,write";
};
请帮帮我◎!另外请问一个问题,怎样给分!
Q: My servlet can find the JavaMail classes, but JavaMail complains that it can't find a service provider for "smtp" or "imap" or address type "rfc822".
A: Usually this is because JavaMail can't access the configuration files in mail.jar, possibly because of a security permission problem; see this item for more details. Also, make sure that you haven't extracted the mail.jar contents; you should include the unmodified mail.jar file in the server's CLASSPATH.
To allow an application to use JavaMail under a JDK 1.2 SecurityManager, the application, JavaMail, and JAF will need permissions such as the following (be sure to replace the host and path names with appropriate values); add these to the security policy file used by the application:
grant {
// following two permissions allow access to default config files
permission java.io.FilePermission "/path/to/mail.jar", "read";
permission java.io.FilePermission
"/path/to/activation.jar", "read";
// following to use SMTP
permission java.net.SocketPermission
"SMTPHOST:25", "connect,resolve";
// following to use IMAP
permission java.net.SocketPermission
"IMAPHOST:143", "connect,resolve";
// following to use POP3
permission java.net.SocketPermission
"POP3HOST:110", "connect,resolve";
// following also to use POP3 in pre-JavaMail 1.2
permission java.io.FilePermission "/path/to/pop3.jar", "read";
// following needed if System.getProperties() is used
permission java.util.PropertyPermission "*", "read,write";
};
请帮帮我◎!另外请问一个问题,怎样给分!
|
你可以getStores()看看有沒有包括SMTP或IMAP﹐如沒有則是mail.jar沒有加到相應的目錄
可以在ClassPath中設置
可以在ClassPath中設置
|
look /jar/lib/security/java.policy
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。