@163 发送邮件部分代码

public static void sendMail(String email, String subject, String emailMsg)
throws AddressException, MessagingException {

	// 1.创建一个程序与邮件服务器会话对象 Session
	Properties props = new Properties();
	props.setProperty("mail.transport.protocol", "SMTP");//发邮件的协议
	props.setProperty("mail.host", "smtp.163.com"); //发送邮件的服务器地址
	props.setProperty("mail.smtp.auth", "true");//指定验证为true

	// 创建验证器
	Authenticator auth = new Authenticator() {
		public PasswordAuthentication getPasswordAuthentication() {
            //发送信息的邮箱账号:XX
			return new PasswordAuthentication("13948869613@163.com", "zhang1025");
		}
	};

	//  相当与邮箱服务器创建连接
	Session session = Session.getInstance(props, auth);

	// 2.创建一个Message,它相当于是邮件内容
	Message message = new MimeMessage(session);
    //发送信息的邮箱账号@163.com: XX@163.com
	message.setFrom(new InternetAddress("13948869613@163.com")); // 设置发送者

	message.setRecipient(RecipientType.TO, new InternetAddress(email)); // 设置发送方式与接收者

	message.setSubject(subject);
	// message.setText("这是一封激活邮件,请<a href='#'>点击</a>");

	message.setContent(emailMsg, "text/html;charset=utf-8");
	message.setSentDate(new Date()); 
	// 3.创建 Transport用于将邮件发送

	Transport.send(message);
}

public String email(){
System.out.println(“1”);
try {
studentService.sendMail("1940679723@qq.com",“这是第二封激活邮件”,“666”);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return NONE;
}

163邮箱的js文件,值得研究! var gContentContainer="divMain"; var gAppName=""; var gVersion=""; var gErrorInfo=""; var gStatus_Ok="S_OK"; var gLogoutUrl="http://www.163.com"; var gMaxThumbSize=3000000; var gMinThumbSize=0; var gIsGetThumb=false; var gUseActivex=true; var gActivexLastVerNo=[1003,1003]; var gUpdateNoTips=false; var gTitle="网易电子邮箱 - "+(location.host.toLowerCase().indexOf("vip.163.com")>-1?"新管家版":"极速3.5"); var gSetLabNew="19"; var gModuleConfig={outLink:{cache:true,request:false,text:"外部链接",tag:0},welcome:{cache:true,request:true,text:"今日",tag:0},read:{cache:true,request:true,text:"读信",tag:0,ajaxApi:"mbox:readMessage",className:"gRead"},readThread:{cache:true,request:false,text:"读信会话",tag:0,className:"gRead"},folderMain:{cache:true,request:false,text:"文件夹",tag:0,ajaxApi:"mbox:getAllFolders",ajaxBody:{stats:true},className:"gFld"},folder:{cache:true,request:true,text:"",tag:0,className:"gIbx",ajaxApi:"mbox:listMessages",isFolder:true},compose:{cache:false,request:false,text:"写信",tag:0,className:"gCmp",innerClass:"gCmp-inner"},send:{cache:false,request:false,text:"发送成功",tag:0},address:{cache:true,request:false,text:"通讯录",tag:0,className:"gCnta",baseExt:"address"},addressCore:{cache:true,request:false,text:"通讯录",tag:0,className:"gCnta"},optionMain:{cache:true,request:false,text:"设置",tag:0,className:"gOpt",baseExt:"option",alias:["option"]},personal:{cache:true,request:true,text:"个人资料",tag:0,className:"gOpt",ajaxApi:"user:getAttrs",ajaxBody:{attrIds:["alt_email","true_name","nick_name","face","gender","remind","mobile_number","home_phone","company_phone","im_account","country","province","city","address","zipcode","company","department","position","fax_number","homepage"]},baseExt:"option"},question:{cache:true,request:true,text:"密码保护",tag:0,className:"gOpt",ajaxApi:"user:getAttrs",ajaxBody:{attrIds:["pwd_hint_question"]},baseExt:"option"},password:{cache:true,request:false,text:"修改密码",tag:0,className:"gOpt",baseExt:"option"},preference:{cache:true,request:false,text:"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值