同步操作将从 Rainy/DocSys 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*** @Title: EmailService.java* @Package com.DocSystem.commonService* @Description: TODO* @author Rainy* @date 2017年8月29日*/package com.DocSystem.commonService;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.net.URLDecoder;import java.util.Calendar;import java.util.Properties;import javax.mail.Authenticator;import javax.mail.PasswordAuthentication;import javax.mail.Session;import javax.mail.Transport;import javax.mail.Message.RecipientType;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeMessage;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import util.ReadProperties;import util.ReturnAjax;/*** ClassName: EmailService* @Description: 邮件类* @author Rainy* @date 2017年8月29日*/@Controller@RequestMapping("email")public class EmailService {public static String fromUser = ReadProperties.read("docSysConfig.properties", "fromuser");private static String fromPwd = ReadProperties.read("docSysConfig.properties", "frompwd");private static String messagetype = ReadProperties.read("docSysConfig.properties", "messagetype");/*** 发送验证码邮件* @param session* @param content* @param toEmail* @return*/@SuppressWarnings("static-access")@ResponseBody@RequestMapping("/sendEmail")public boolean sendEmail(ReturnAjax rt, String toEmail,String content){try {Properties props = new Properties();String basePath = new EmailService().getClass().getClassLoader().getResource("/").getPath();File config = new File(basePath+"docSysConfig.properties");InputStream in = new FileInputStream(config);props.load(in);Session mailSession = Session.getInstance(props,new MyAuthenticator(fromUser,fromPwd));InternetAddress fromAddress = new InternetAddress(fromUser);InternetAddress toAddress = new InternetAddress(toEmail);MimeMessage message = new MimeMessage(mailSession);message.setFrom(fromAddress);message.addRecipient(RecipientType.TO, toAddress);message.setSentDate(Calendar.getInstance().getTime());message.setSubject("来自MxsDoc的邮件");if(content!=null&&!"".equals(content)){content = URLDecoder.decode(content, "UTF-8");message.setContent(EmailService.getEmailHtmlByCode(content), messagetype);}else{rt.setError("发送系统邮件失败!");return false;}Transport transport = mailSession.getTransport("smtp");transport.send(message, message.getRecipients(RecipientType.TO));rt.setMsgInfo("发送系统邮件成功!");return true;} catch (Exception e) {e.printStackTrace();rt.setError("发送系统邮件失败!");}return false;}public static String getEmailHtmlByCode(String content){String emailContent = "<style type='text/css'>"+" body{"+" font-family: 'arial'; font-size:12px;"+" }"+" .email-content{"+" padding:50px;"+" width: 80%;"+" }"//+" p{"//+" color:cornflowerblue;"//+" }"+" p.firstline{"+" padding-left: 24px;"+" }"+" a{"+" color:#A3A3A3;"+" }"+" a:hover{"+" color:deepskyblue;"+" }"+" </style>"+" <div class='email-content'>"// +" <p>尊敬的MxsDoc用户:</p>"+" <p class='firstline'>"+ content+" </p>"+" </div>";return emailContent;}class MyAuthenticator extends Authenticator{String userName="";String password="";public MyAuthenticator(){}public MyAuthenticator(String userName,String password){this.userName=userName;this.password=password;}protected PasswordAuthentication getPasswordAuthentication(){return new PasswordAuthentication(userName, password);}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。