weixin_36882430 2016-12-15 08:19 采纳率: 37%
浏览 933

还是发送邮件的问题。这个是发送邮件的方法,是哪里导致出错的呢?

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);
} 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条回答 默认 最新

  • 代码的灵魂是bug! 2016-12-15 09:43
    关注

    把错误提示贴出来啊,光是代码谁知道啊

    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制