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()>

本文标签: 验证码邮箱功能