weixin_36882430 2016-12-21 06:43 采纳率: 37%
浏览 897

发送邮件 类和变量都正确,就是接收不到。是哪里写错了吗?

public void sendCodeByEmail(String email, String account, String code) {
// 验证码生成
String vcode = "";
for (Integer i = 0; i < 4; i++) {
int in = (int) (Math.random() * 10);
if (in == 0) {
in = 1;
}
vcode = vcode + in;
}
Map map = new HashMap();
map.put("account", account);
map.put("vcode", vcode);
map.put("email", email);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
map.put("date", format.format(new Date()));
// 验证信息
CompanyValidate validate = new CompanyValidate();
validate.setTargetName(email);
validate.setVcode(vcode);
validate.setTargetType(TYPE_EMAIL);// 邮箱验证
// 保存验证信息
companyValidateDao.insertValidate(validate);
String key = "";
try {
key = MD5.encode(account + email + vcode);
map.put("key", key);
} catch (Exception e) {
return;
}
// 发送邮件
String sms_flag = (String) MemcachedUtils.getInstance().getClient()
.get("baseConfig.sms.flag");
if ("true".equals(sms_flag)) {
if (code.equals("0")) {
map.put("address", AddressTool.getAddress("www")
+ "/doValidEmail.htm?key=" + key + "&account" + account
+ "&vcode=" + vcode);
MailUtil.getInstance().sendMail("邮件密码找回", email,
"feiliao91-pwd-mail", map, 0);
System.out.println(map);
} else if (code.equals("1")) {
map.put("address", AddressTool.getAddress("trade")
+ "/security/unValidEmail.htm?key=" + key + "&account="
+ account + "&vcode=" + vcode + "&email=" + email);
MailUtil.getInstance().sendMail("邮件解绑", email,
"feiliao91-email-mailUnbind", map, 0);
} else if (code.equals("2")) {
map.put("address", AddressTool.getAddress("trade")
+ "/security/doValidEmail.htm?key=" + key + "&account="
+ account + "&vcode=" + vcode + "&email=" + email);
MailUtil.getInstance().sendMail("邮件绑定", email,
"feiliao91-email-mailBind", map, 0);
}
} else {
// 本地打印信息
System.out.println(map);
}

}
  • 写回答

1条回答 默认 最新

  • JPF1024 2016-12-21 07:01
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?