admin管理员组文章数量:1529460
在进行实际项目的开发过程中,我们可能会遇到需要需要对用户账号密码进行找回,这时就需要我们通过邮件进行验证,从而对用户信息进行修改,下面我就将自己开发过程中的邮件发送功能简单描述一下,供大家学习使用。
1.MailSenderInfo是确定邮件发送的类型及其各种属性
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class MailSenderInfo {
private String mailServerHost; //发送邮件的服务器
private String mailServerPort="587"; //发送邮件的服务器的端口
private String fromAddress; //发送者地址
private String toAddress; //接收者地址
private String username; //发送者用户名
private String password; //发送者密码
private boolean validate=true; //是否需要身份验证
private String subject; //邮件主题
private String content; //邮件内容
private Map<String, String> mailType; //邮箱类型
//得到邮件会话属性
public Properties getProperties(){
Properties p = new Properties();
p.put("mail.smtp.host", this.mailServerHost);
p.put("mail.smtp.port", this.mailServerPort);
p.put("mail.smtp.auth", validate?"true":"false");
return p;
}
public String getMailServerHost() {
return mailServerHost;
}
public void setMailServerHost(String mailServerHost) {
this.mailServerHost = mailServerHost;
}
public String getMailServerPort() {
return mailServerPort;
}
public void setMailServerPort(String mailServerPort) {
this.mailServerPort = mailServerPort;
}
public String getFromAddress() {
return fromAddress;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
public String getToAddress() {
return toAddress;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
this.fromAddress=username;
if(username!=null&&username.length()>
版权声明:本文标题:邮箱验证码功能实现 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726722091a1081909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论