action中调用EmailUtil中的sendHtmlMail方法:
public void forgetPassword() throws Exception {
String email = request.getParameter("email");
User u=userService.getByEmail(email);
Json json=new Json();
if (StrUtils.isNotBlank(email) && u!=null ) {
String key=ConfigUtil.get("key");
String data = u.getId()+","+new Date().getTime();
String secret = URLEncoder.encode(Secret.encrypt(data, Secret.md5(key.getBytes())), "utf-8");
log.debug("加密后:"+secret);
StringBuffer content=new StringBuffer();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
content.append("重设密码:");
content.append(secret);
content.append("
"+DateFactory.getDateTime()+"
");String conMsg=content.toString();
try{
log.debug("+++++++++"+conMsg);
EmailUtil.sendHtmlMail("忘记密码,将密码设为默认密码!", content.toString(), null, email);
}catch(Exception e){
json.setSuccess(false);
json.setMsg("发送失败!");
}
json.setSuccess(true);
json.setMsg("发送成功!");
}else{
json.setMsg("该邮箱还没有注册,请检查输入!");
json.setSuccess(false);
}
writeJson(json);
}
这是一个实现往邮箱发邮件的功能,要调用的功能没有错,测试类中调用可以实现发邮件,但是在action中写的方法就是不能调用到该方法,没有执行