社区
Java SE
帖子详情
jmail中smtp验证问题?
xiaoxiao1987918
2008-07-10 05:39:03
我用公司的用户名在公司的企业邮局里可以任意的发邮件,可是用"smtp.163.com"或者其他的就不可以发了。而且还出了个异常
java.lang.SecurityException:Access to default session denied
请问各位高手,这是咋回事啊?(163的用户名和密码都是正确的)
...全文
201
8
打赏
收藏
jmail中smtp验证问题?
我用公司的用户名在公司的企业邮局里可以任意的发邮件,可是用"smtp.163.com"或者其他的就不可以发了。而且还出了个异常 java.lang.SecurityException:Access to default session denied 请问各位高手,这是咋回事啊?(163的用户名和密码都是正确的)
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
victor_woo
2008-07-11
打赏
举报
回复
我看了自己的代码,我用的是m_objSession = Session.getInstance(m_properties,m_objAuthenticator);
其他一模一样,呵呵
好久没有用了,刚刚试一下,还可以发出去
我的是126的邮箱
xiaoxiao1987918
2008-07-11
打赏
举报
回复
围绕我几天的问题解决了!!!呵呵
不是代码的问题,是 server的问题,把weblogic 服务重启一次就可以发了!
xiaoxiao1987918
2008-07-11
打赏
举报
回复
有谁能帮我看看代码,还有哪里没注意到的???
//身份验证类
package com.rlis.model;
import javax.mail.PasswordAuthentication;
/**
* Eway邮件认证信息
*
*/
public class EwayAuthenticator extends javax.mail.Authenticator {
private String account; //帐号
private String password; //密码
/**
* 构造函数赋值
* @param user 帐号
* @param password 密码
*/
public EwayAuthenticator(String user, String password) {
this.account = user;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(account, password);
}
/**
* @return the account
*/
public String getAccount() {
return account;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
}
//发送邮件方法
public boolean sendEmail(String smtpServer, EwayAuthenticator authenticator, EmailInfo emailInfo)
throws UserException
{
logger.info("Sendinging email message: (fromAddress:"+authenticator.getAccount()+"," +
"toAddress:"+((InternetAddress)emailInfo.getToAddresses()[0]).getAddress()+")");
boolean returnResult = false;
Properties props = System.getProperties();
try {
props.put("mail.smtp.host", "stmp.sina.com");
props.put("mail.smtp.port", 25);
// Get session
props.put("mail.smtp.auth", "true"); // 这样才能通过验证
EwayAuthenticator myauth = new EwayAuthenticator(authenticator.getAccount(),authenticator.getPassword());
Session session = Session.getDefaultInstance(props, myauth);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(authenticator.getAccount()));
msg.setRecipients(javax.mail.Message.RecipientType.TO, emailInfo.getToAddresses());
msg.setSubject(emailInfo.getSubject());
msg.setHeader("X-Mailer", "regmailer");
msg.setSentDate(new Date());
msg.setDataHandler(new DataHandler(emailInfo.getContent(), "text/html"));
Transport tran = (Transport) session.getTransport("smtp");
tran.connect(smtpServer,authenticator.getAccount(),authenticator.getPassword());
tran.send(msg);
} catch (Exception ex) {
logger.error("Error sending email message: "+ ex);
throw new UserException("Error sending email message: "
+ ex);
}
}
xiaoxiao1987918
2008-07-11
打赏
举报
回复
再请教各位一个问题,我发出邮件内容,都给显示成了(????????)了,那编码格式要怎么设置啊?
mackson
2008-07-10
打赏
举报
回复
tom稍微稳定一点
xiaoxiao1987918
2008-07-10
打赏
举报
回复
我自己的是2006年,我后来问我同事要了个几年前的邮箱,可是还是出这样的异常!郁闷啊!
lovingprince
2008-07-10
打赏
举报
回复
有时候要看你的163邮箱帐号知否支持smtp功能。现在126就有这种限制,在2006年还是2007年几月份开始申请的新邮箱都不能使用POP3功能,非常郁闷。
jmail
邮件发送示例
·基于 Dimac w3
Jmail
4.3 ActiveX控件,支持
SMTP
服务器发信身份
验证
·核心过程错误保护,对输入的信息进行客户端与服务器端双重检测 ·支持同时向多个收件人进行发送,直接用“,”分隔 ·单一文件方便管理
V-
Jmail
在线邮件发送系统.rar
基于 Dimac w3
Jmail
v4.3 组件的网页邮件发送系统,...支持
SMTP
服务器发信身份
验证
,核心过程错误保护,对输入的信息进行客户端与服务器端双重检测,支持同时向多个收件人进行发送,直接用“,”分隔 单一文件方便管理
Slunc-
Jmail
在线发送邮件系统 v1.2.rar
·基于 Dimac w3
Jmail
4.3 ActiveX控件,支持
SMTP
服务器发信身份
验证
·核心过程错误保护,对输入的信息进行客户端与服务器端双重检测 ·支持同时向多个收件人进行发送,直接用“,”分隔 ·单一文件方便管理 ...
V-
Jmail
在线邮件发送系统
基于 Dimac w3
Jmail
v4.3 组件的网页邮件发送系统,...支持
SMTP
服务器发信身份
验证
,核心过程错误保护,对输入的信息进行客户端与服务器端双重检测,支持同时向多个收件人进行发送,直接用“,”分隔 单一文件方便管理
phpwind2.0邮件增强插件(支持e
smtp
)
1 使用默认mail函数 2 通过SOCKET连接
SMTP
服务器发送(支持 E
SMTP
验证
) 3 通过调用CDONTS.NewMail(虚拟
SMTP
发信)组件发送Email(仅 win32 下有效) 4 通过调用
jmail
组件发送Email(仅 win32 下有效...
Java SE
62,612
社区成员
307,332
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章