|
|
|
请问javamail中的smtp host需要密码验证怎么办?
|
2004年10月07日 12:44
|
|
|
标签列表
|
|
|
用java法送邮件的时候,在smtp中String host="mail.sohu.com"。可是对方的smtp服务器有密码用户验证,该怎么写这个host呢,或者有其他的方法解决吗?请各位高手不吝赐教。多谢了。
|
|
|
|
|
|
Re: 请问javamail中的smtp host需要密码验证怎么办?
|
2004年10月08日 21:28
|
|
|
|
目前的SMTP HOST都需要密码验证的,目前占主流的javamail理论上可绕过验证,好象目前还是没有实现,我自己以前做项目的时候,架构师却说可以,而且实现了,我现在还不明白,
|
|
|
|
|
|
Re: 请问javamail中的smtp host需要密码验证怎么办?
|
2004年10月14日 14:44
|
|
|
String mailHost = resourceBundle.getString("mailHost"); String authUser = resourceBundle.getString("authUser"); String authPassword = resourceBundle.getString("authPassword");
EmailAutherticator autherticator = new EmailAutherticator(authUser,authPassword); Properties props = System.getProperties(); if (mailHost != null) { props.put("mail.smtp.host", mailHost); props.put("mail.smtp.auth", "true"); }
class EmailAutherticator extends Authenticator { private String userName = null;
private String password = null;
public EmailAutherticator(String userName, String password) { super(); this.userName = userName; this.password = password; }
public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(userName, password); } }
|
|
|
|