use of com.itrus.portal.db.EmailServer in project portal by ixinportal.
the class EmailServerController method create.
/**
* 添加/更新邮箱页面
*
* @return
*/
@RequestMapping(params = "form", produces = "text/html")
public String create(@RequestParam(value = "id", required = false) Long id, Model uiModel) {
if (id == null) {
return "mailconfig/create";
}
try {
EmailServer emailServer = emailServerService.getEmailServerByID(id);
uiModel.addAttribute("emailServer", emailServer);
} catch (Exception e) {
e.printStackTrace();
uiModel.addAttribute("errMsg", "解密密码失败");
}
return "mailconfig/create";
}
use of com.itrus.portal.db.EmailServer in project portal by ixinportal.
the class SendEmailImpl method sendEmail.
/**
* 发送邮件 目前支持smtp协议
*
* @param mailContent
* 邮件内容
* @param toEmail
* 接收人
* @param subject
* 邮件主题
* @param isHtml
* 是否为html格式
* @throws MessagingException
*/
public void sendEmail(String mailContent, String[] toEmail, String subject, boolean isHtml) throws MessagingException, Exception {
// 发送邮件
EmailServer emailServer = emailServerService.getEmailServerByExample(new EmailServerExample());
sendEmail(emailServer, mailContent, toEmail, subject, isHtml);
}
use of com.itrus.portal.db.EmailServer in project portal by ixinportal.
the class SendEmailImpl method sendEmail.
/**
* 发送邮件加附件(照片)
* @param mailContent
* 邮件内容
* @param toEmail
* 接收人
* @param subject
* 邮件主题
* @param isHtml
* 是否为html格式
* @param porxyMap
* 授权书
* @throws MessagingException
* @throws Exception
*/
public void sendEmail(String mailContent, String[] toEmail, String subject, boolean isHtml, Map<String, File> porxyMap) throws MessagingException, Exception {
// 发送邮件
EmailServer emailServer = emailServerService.getEmailServerByExample(new EmailServerExample());
sendEmailAndPorxy(emailServer, mailContent, toEmail, subject, isHtml, porxyMap);
}
use of com.itrus.portal.db.EmailServer in project portal by ixinportal.
the class EmailServerService method getEmailServerByExample.
public EmailServer getEmailServerByExample(EmailServerExample example) throws Exception {
List<EmailServer> esList = sqlSession.selectList("com.itrus.portal.db.EmailServerMapper.selectByExample", example);
if (esList == null || esList.isEmpty())
return null;
EmailServer emailServer = esList.get(0);
// 解密密码
if (StringUtils.isNotBlank(emailServer.getAccountPasswd()) && Base64.isBase64(emailServer.getAccountPasswd().getBytes()))
emailServer.setAccountPasswd(AESencrp.decrypt(emailServer.getAccountPasswd(), dbEncKey));
return emailServer;
}
use of com.itrus.portal.db.EmailServer in project portal by ixinportal.
the class EmailServerService method updateEmailServer.
// 根据已有ID,更新邮箱配置信息
public void updateEmailServer(EmailServer emailServer) throws ServiceNullException, Exception {
if (emailServer == null || emailServer.getId() == null)
throw new ServiceNullException("要更新的邮件配置为空");
EmailServer es1 = getEmailServerByID(emailServer.getId());
if (es1 == null)
throw new ServiceNullException("要更新的邮件配置不存在");
// 如果密码不为空,则使用原来的密码
if (StringUtils.isNotBlank(emailServer.getAccountPasswd()))
emailServer.setAccountPasswd(AESencrp.encrypt(emailServer.getAccountPasswd(), dbEncKey));
emailServer.setCreateTime(es1.getCreateTime());
emailServer.setLastModify(new Date());
sqlSession.update("com.itrus.portal.db.EmailServerMapper.updateByPrimaryKey", emailServer);
}
Aggregations