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

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个回答

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

weixin_36882430
weixin_36882430 需要什么错? 没报什么错啊,就是不能发送邮件。
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐