当前位置: 技术问答>java相关
用javamail发邮件,怎麽才能通过smtp的验证
来源: 互联网 发布时间:2015-02-26
本文导语: as title | 文件一:MyAuthenticator.java 用途: 返回一个PasswordAuthentication 类的对象。 import javax.mail.PasswordAuthentication; import javax.mail.Authenticator; public class MyAuthenticator extends Authenticator { public...
as title
|
文件一:MyAuthenticator.java
用途: 返回一个PasswordAuthentication 类的对象。
import javax.mail.PasswordAuthentication;
import javax.mail.Authenticator;
public class MyAuthenticator extends Authenticator {
public MyAuthenticator() {
super();
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("用户名","用户密码");
}
}
用途: 返回一个PasswordAuthentication 类的对象。
import javax.mail.PasswordAuthentication;
import javax.mail.Authenticator;
public class MyAuthenticator extends Authenticator {
public MyAuthenticator() {
super();
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("用户名","用户密码");
}
}