mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2025-09-01 11:26:56 +00:00
58 lines
1.1 KiB
Java
58 lines
1.1 KiB
Java
package pw.yumc.YumCore.mail;
|
|
|
|
import javax.mail.Authenticator;
|
|
import javax.mail.PasswordAuthentication;
|
|
|
|
/**
|
|
* 服务器邮箱登录验证
|
|
*
|
|
* @author MZULE
|
|
*
|
|
*/
|
|
public class MailAuthenticator extends Authenticator {
|
|
|
|
/**
|
|
* 用户名(登录邮箱)
|
|
*/
|
|
private String username;
|
|
/**
|
|
* 密码
|
|
*/
|
|
private String password;
|
|
|
|
/**
|
|
* 初始化邮箱和密码
|
|
*
|
|
* @param username
|
|
* 邮箱
|
|
* @param password
|
|
* 密码
|
|
*/
|
|
public MailAuthenticator(String username, String password) {
|
|
this.username = username;
|
|
this.password = password;
|
|
}
|
|
|
|
public void setPassword(String password) {
|
|
this.password = password;
|
|
}
|
|
|
|
public void setUsername(String username) {
|
|
this.username = username;
|
|
}
|
|
|
|
@Override
|
|
protected PasswordAuthentication getPasswordAuthentication() {
|
|
return new PasswordAuthentication(username, password);
|
|
}
|
|
|
|
String getPassword() {
|
|
return password;
|
|
}
|
|
|
|
String getUsername() {
|
|
return username;
|
|
}
|
|
|
|
}
|