| | |
| | | pubkey:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB" |
| | | }; |
| | | let telCoeKey; |
| | | (function($) { |
| | | $.Read=function(){ |
| | | (function($) { |
| | | $.Read=function(){ |
| | | var _this=this; |
| | | var select; |
| | | var browserName = myexplorer(); |
| | | $(".get_phoneCode").addClass('is-disabled'); |
| | | $('.get_phoneCode').attr('disabled', true); |
| | | if (browserName && browserName != "" && browserName != "谷歌") { |
| | | $(".tips").show(); |
| | | $(".tips").show(); |
| | | alert("您正在使用 " + browserName +" 浏览器,强烈推荐您使用【谷歌】浏览器登录系统!"); |
| | | }else { |
| | | $(".tips").hide(); |
| | | $(".tips").hide(); |
| | | } |
| | | |
| | | |
| | | if(window.parent.length>0){ |
| | | window.parent.location=hostUrl+'/login.jsp'; |
| | | } |
| | | |
| | | |
| | | if($("#snDiv").is(":visible")){ |
| | | $("#cltsn").focus(); |
| | | $("#cltsn").focus(); |
| | | } else{ |
| | | $("#name").focus(); |
| | | $("#name").focus(); |
| | | } |
| | | |
| | | |
| | | //系统下拉选择 |
| | | this.setDate=function(event){ |
| | | if(event.selectedIndex!=-1){ |
| | |
| | | }); |
| | | //设置有LOGO加载 |
| | | $('.login_logo img').attr('src','/getLogoIcon.do?dbid='+event.value); |
| | | } |
| | | select=event; |
| | | } |
| | | select=event; |
| | | } |
| | | |
| | | this.reloadCode=function(i,event) { |
| | | |
| | | this.reloadCode=function(i,event) { |
| | | if(null!=event){ |
| | | event.src="/imageCode?rand="+i; |
| | | } |
| | | event.src="/imageCode?rand="+i; |
| | | } |
| | | } |
| | | this.reloadTelCode=function (){ |
| | | $.get('/ws/captcha/get.do',function(r){ |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | this.disableButton=function(){ |
| | | $("#sub").attr("disabled",true); |
| | | $("#sub").css("background-color","#bec4c8"); |
| | |
| | | $("#cltsn").addClass("errorinput"); |
| | | } |
| | | flg=true; |
| | | } |
| | | } |
| | | if($("#name").val()=="" && isAccount){ |
| | | $(".name").find("span").html("请输入账号 / 手机号"); |
| | | $("#name").addClass("errorinput"); |
| | |
| | | $("#phoneCode").addClass("errorinput"); |
| | | flg=true; |
| | | } |
| | | |
| | | |
| | | if(flg){ |
| | | removeDisableButton(); |
| | | return false; |
| | | } |
| | | |
| | | if(!flg && ""==select.value && isonescore==""){ |
| | | if(!flg && ""==select.value && isonescore==""){ |
| | | $(".login_select").find("span").html("请选择一个系统"); |
| | | if(!$(".select").hasClass('l_select')){ |
| | | $(".select").addClass('l_select'); |
| | |
| | | }else if($("#telephone").val()!="" && $("#phoneCode").val()!=""){ |
| | | //短信登录 |
| | | loginRequest("","",select.value); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | $("#name").keydown(function(e){ |
| | | var e=e||window.event; |
| | | if(e.keyCode==13){//回车键 |
| | | $("#pwd").focus(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | $("#pwd").keydown(function(e){ |
| | | var e=e||window.event; |
| | | if(e.keyCode==13){//回车键 |
| | |
| | | return; |
| | | } |
| | | $("#sub").click(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | $("#code").keydown(function(e){ |
| | | var e=e||window.event; |
| | | if(e.keyCode==13){//回车键 |
| | | $("#sub").click(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | $("#reset").click(function(){ |
| | | $("#name").val(""); |
| | | $("#pwd").val(""); |
| | | $("#code").val(""); |
| | | $("#name").focus(); |
| | | |
| | | }); |
| | | |
| | | }); |
| | | // $("#ppwd").keyup(function() { |
| | | // $("#pwd").val(hex_md5($("#ppwd").attr("value"))); |
| | | |
| | | // $("#pwd").val(hex_md5($("#ppwd").attr("value"))); |
| | | |
| | | // }); |
| | | |
| | | |
| | | // $(".sub_button").click(function(){ |
| | | // _this.initValue(); |
| | | // }); |
| | | |
| | | $("#randomming").click(function(){ |
| | | _this.reloadCode(Math.random(),this); |
| | | _this.reloadCode(Math.random(),this); |
| | | }); |
| | | $("#telimage").click(function(){ |
| | | // 获取验证码 |
| | |
| | | }); |
| | | $(".pop-sns-qq-m").on("touchend",function () { |
| | | $(".icon-qq-m").removeClass("qq-hover"); |
| | | }); |
| | | |
| | | }); |
| | | |
| | | $("#dataName").change(function(){ |
| | | _this.setDate(this); |
| | | }); |
| | | |
| | | |
| | | $("#dataName").click(function(){ |
| | | _this.setDate(this); |
| | | }); |
| | | $("#dataName").triggerHandler('click'); |
| | | $("#randomming").triggerHandler('click'); |
| | | |
| | | |
| | | $(".pop-sns-weixin").click(function () { |
| | | if(select.selectedIndex==-1){ |
| | | alert("必须选择一个账套"); |
| | |
| | | } |
| | | }); |
| | | }catch(e){ |
| | | |
| | | } |
| | | |
| | | } |
| | | //location = oauth2HostName+"/oauth2/weixin.do?"+SessionKey+"="+select.value+"&orghost="+hostUrl; |
| | | }); |
| | | |
| | | |
| | | $(".pop-sns-qq").click(function () { |
| | | if(select.selectedIndex==-1){ |
| | | alert("必须选择一个账套"); |
| | |
| | | // |
| | | // } |
| | | //location =oauth2HostName+"/oauth2/qq.do?"+SessionKey+"="+select.value+"&orghost="+hostUrl; |
| | | }); |
| | | }); |
| | | |
| | | //maintaince.dbid=select.value; |
| | | // maintaince.isStop='false'; |
| | | //setInterval(maintaince.checkSysIsExpired, 10000);//10秒调用一次 |
| | | //checkSysIsExpired('<%=dbId%>','false'); //检查系统是否停止使用 Added by Johns Wang ,2017-05-26 |
| | | |
| | | |
| | | |
| | | |
| | | // 登录方式切换 |
| | | $(".nav_tab").on("click", function () { |
| | | if(!$(this).hasClass('active')){ |
| | |
| | | if(!$(this).hasClass("active")){ |
| | | $(this).addClass("active"); |
| | | $('.login-password').hide(); |
| | | $('.qrcode-logins').show(); |
| | | $('.qrcode-logins').show(); |
| | | //获取二维码 |
| | | _this.createqrCode(); |
| | | _this.createqrCode(); |
| | | }else{ |
| | | if(webSocket!=null){ |
| | | $(this).removeClass("active"); |
| | |
| | | $('.qrcode-logins').hide(); |
| | | webSocketClose();//关闭链接 |
| | | webSocket=null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | // 获取验证码按钮 |
| | | var countTime = 60; //倒计时时间 |
| | |
| | | return; |
| | | } |
| | | var phone=$("#telephone").val(); |
| | | if(!(/^1[3456789]\d{9}$/.test(phone))){ |
| | | if(!(/^1[3456789]\d{9}$/.test(phone))){ |
| | | $(".telephone").find("span").html("请输入正确的手机号码"); |
| | | $("#telephone").addClass("errorinput"); |
| | | return; |
| | | return; |
| | | } |
| | | $(".get_phoneCode").addClass('is-disabled'); |
| | | $('.get_phoneCode').attr('disabled', true); |
| | |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | |
| | | //二维码过期刷新 |
| | | $('.qrcode-error a').on('click',function(){ |
| | | //获取二维码 |
| | | _this.createqrCode(); |
| | | _this.createqrCode(); |
| | | }); |
| | | |
| | | |
| | | //生成二维码图片 |
| | | this.createqrCode=function(){ |
| | | $(".qrcode-error").hide(); |
| | | $(".qrcode-error").hide(); |
| | | $.post("/ws/qrCode.do?appId="+select.value,function(res){ |
| | | if(res!=null && res.code==0){ |
| | | $(".qrcode-logins").find("img").attr("src",res.data.url); |
| | | initWebSocket(hostUrl+"/ws/qrLogin/"+select.value+"/"+res.data.qrcode+"/0",res.data.qrcode); |
| | | }else{ |
| | | alert(res.msg); |
| | | webSocket=-1; |
| | | } |
| | | },"json").error(function(e){ |
| | | if (res != null && res.code == 0) { |
| | | $(".qrcode-logins").find("img").attr("src", res.data.url); |
| | | initWebSocket(hostUrl + "/ws/qrLogin/" + select.value + "/" + res.data.qrcode + "/0", res.data.qrcode); |
| | | } else { |
| | | if (res.data != null && res.data != '') { |
| | | alert(res.data); |
| | | } else { |
| | | alert(res.msg); |
| | | } |
| | | webSocket = -1; |
| | | } |
| | | },"json").error(function(e){ |
| | | webSocket=-1; |
| | | alert(e.responseText); |
| | | $(".qrcode-logins").find("img").attr("src",""); |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | })(jQuery); |
| | | } |
| | | })(jQuery); |
| | | //登录请求 |
| | | function loginRequest(encryptUser,encryptPwd,dataName){ |
| | | $.ajax({ |
| | |
| | | var url=$("#hostUrl").val()+"/home.jsp"; |
| | | if(redirect!=""){ |
| | | url+="?redirect="+redirect; |
| | | } |
| | | window.location.replace(url); |
| | | } |
| | | window.location.replace(url); |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取待处理邮件列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/getHandleMailList.do") |
| | | public AllBackMsg getHandleMailList(String mail, HttpServletRequest request, HttpServletResponse response) throws Exception { |
| | | AllBackMsg msg = new AllBackMsg(); |
| | | try { |
| | | if (StringUtils.isNotBlank(mail)) { |
| | | if (!EMAIL_PATTERN.matcher(mail).matches()) { |
| | | msg.setFail("邮箱的各式不争取"); |
| | | return msg; |
| | | } |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE);//当前登录用户 |
| | | if (StringUtils.isBlank(userCode)) {//获取不到当前用户直接结束 |
| | | msg.setFail("获取不到用户信息"); |
| | | return msg; |
| | | } |
| | | DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息 |
| | | SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源 |
| | | List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode); |
| | | if (t482101HEntityList.size() > 0) { |
| | | msg.setSuccess("执行完成", t482101HEntityList); |
| | | } |
| | | } catch (Exception e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * 获取邮件详情 |
| | | * |
| | | * @return |
| | |
| | | List<String> list = new ArrayList<>(); |
| | | if (attachmentEntities.size() > 0) { |
| | | for (AttachmentEntity a : attachmentEntities) { |
| | | list.add(shoppingImageServer + "/uploads/attachment/"+dataSourceEntity.getDbId()+"/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile()); |
| | | list.add(shoppingImageServer + "/uploads/attachment/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile()); |
| | | } |
| | | t482101HEntity.setAttachmentPath(list); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 快速回复 |
| | | * |
| | | * @return |
| | | */ |
| | | @PostMapping("/setQuickReply.do") |
| | | public AllBackMsg setQuickReply(@RequestBody Map<String, Object> reply, HttpServletRequest request, HttpServletResponse response) throws Exception { |
| | | AllBackMsg msg = new AllBackMsg(); |
| | | try { |
| | | if (reply.get("docCode") == null) { |
| | | msg.setFail("获取不到回复邮件的唯一docCode值"); |
| | | return msg; |
| | | } |
| | | if (reply.get("content") == null) { |
| | | msg.setFail("请输入回复内容"); |
| | | return msg; |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE);//当前登录用户 |
| | | if (StringUtils.isBlank(userCode)) {//获取不到当前用户直接结束 |
| | | msg.setFail("获取不到用户信息"); |
| | | return msg; |
| | | } |
| | | String docCode = (String) reply.get("docCode");//编号 |
| | | String content = (String) reply.get("content");//内容 |
| | | Integer count = mailServiceIfc.setQuickReply(docCode, content); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (count.equals(1)) { |
| | | map.put("code", 0); |
| | | map.put("docCode", docCode); |
| | | map.put("msg", "邮件已回复"); |
| | | msg.setSuccess("执行成功", map); |
| | | } else { |
| | | map.put("code", -1); |
| | | map.put("docCode", docCode); |
| | | map.put("msg", "邮件回复失败"); |
| | | msg.setSuccess("执行成功", map); |
| | | } |
| | | } catch (Exception e) { |
| | | msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * 保存草稿箱(保存或修改) |
| | | * |
| | | * @return |
| | |
| | | private Integer mailType;// [note: '0:草稿箱1:收件箱2:发件箱'] |
| | | private String senderName;//发件人名称 |
| | | private String sender;// [note:'发送人'] |
| | | private List<String> receiver = new ArrayList<>(); |
| | | private List<String> receiver = new ArrayList<>();//收件人集合 |
| | | private Integer folderId = 0;// [note:'文件夹id'] |
| | | private Integer deleteFlag = 0; //[note:'是否已删除'] |
| | | private Integer readFlag = 0;// [note:'是否已读'] |
| | |
| | | List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode); |
| | | |
| | | /** |
| | | * 获取待处理邮件列表 |
| | | * @param email |
| | | * @return |
| | | */ |
| | | List<t482101HList> getHandleMailList(String email,String userCode); |
| | | |
| | | /** |
| | | * 获取用户的全部邮件 |
| | | * |
| | | * @param userCode |
| | |
| | | "@physicalFile varchar(50),@OriginalPicture varbinary(max) \n"; |
| | | sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n"; |
| | | sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,senderName,sender,receiver," + |
| | | "cc,bcc,subject,userCode,userName,content,plain_text,messageId,read_flag,delete_flag,create_time,update_time,receive_time," + |
| | | "cc,bcc,subject,userCode,userName,content,plain_text,messageId,read_flag,delete_flag,create_time,update_time," +//receive_time |
| | | "attach_flag,attachment_list) values "; |
| | | sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," + |
| | | "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120)," |
| | |
| | | GridUtils.prossSqlParm(StringUtils.join(m.getBcc(), ",")) + "," + |
| | | GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + |
| | | GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getPlainText()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," + |
| | | m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + GridUtils.prossSqlParm(m.getReceiveTime()) + "," + m.getAttachFlag() + "," + |
| | | GridUtils.prossSqlParm(m.getAttachmentList()) + ") \n" + |
| | | m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + m.getAttachFlag() + "," + GridUtils.prossSqlParm(m.getAttachmentList()) + ") \n" + |
| | | mailFileSql(m.getMailFile()); |
| | | sql += "select @docCode as docCode"; |
| | | String docCode = jdbcTemplate.queryForObject(sql, String.class); |
| | |
| | | for (t482101HEntity m : mail) {//遍历内容 |
| | | sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n"; |
| | | sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,senderName,sender,receiver," + |
| | | "cc,bcc,subject,userCode,userName,content,plain_text,messageId,read_flag,delete_flag,create_time,update_time,receive_time," + |
| | | "cc,bcc,subject,userCode,userName,content,plain_text,messageId,read_flag,delete_flag,create_time,update_time," + |
| | | "attach_flag,attachment_list) values "; |
| | | sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," + |
| | | "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120)," |
| | |
| | | GridUtils.prossSqlParm(StringUtils.join(m.getBcc(), ",")) + "," + |
| | | GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + |
| | | GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getPlainText()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," + |
| | | m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + GridUtils.prossSqlParm(m.getReceiveTime()) + "," + |
| | | m.getAttachFlag() + "," + GridUtils.prossSqlParm(m.getAttachmentList()) + ") \n" + |
| | | m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + m.getAttachFlag() + "," + GridUtils.prossSqlParm(m.getAttachmentList()) + ") \n" + |
| | | mailFileSql(m.getMailFile()); |
| | | } |
| | | jdbcTemplate.update(sql); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<t482101HList> getHandleMailList(String email, String userCode) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "select companyId,companyName,mailType,DocCode,senderName,sender,receiver,subject,plain_text," + |
| | | "receive_time,update_time,create_time,senderName,sender,userCode,userName,folder_id,delete_Flag, " + |
| | | "read_Flag,(case when (isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate()) then 1 else 0 end) as handle," + |
| | | "handle_time from t482101H "; |
| | | sql += " where isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate()"; |
| | | sql += " and userCode=" + GridUtils.prossSqlParm(userCode) + " and receiver like '%" + email + "%'"; |
| | | return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(t482101HList.class)); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<t482101HList> getUserMailList(String userCode) { |
| | | String sql = " set nocount on \n"; |
| | | try { |
| | |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateRead(String docCode, boolean status) { |
| | |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateMailHandle(String handleTime, String docCode) { |
| | |
| | | * @throws IOException |
| | | */ |
| | | abstract void sendEmails(t482101HEntity t482101H, HttpServletRequest request) throws Exception; |
| | | |
| | | /** |
| | | * 快速回复 |
| | | * @param docCode |
| | | * @param content |
| | | * @return |
| | | */ |
| | | Integer setQuickReply(String docCode,String content) throws MessagingException; |
| | | } |
| | |
| | | String pwd = emailEntity.getReceivePassword();//密码 |
| | | |
| | | Properties properties = new Properties(); |
| | | properties.put("mail.store.protocol", protocol); // IMAP over SSL |
| | | properties.setProperty("mail.store.protocol", protocol); // IMAP over SSL |
| | | if (protocol.contains("imap")) {//接收协议imap |
| | | properties.put("mail.imaps.host", server); |
| | | properties.put("mail.imaps.port", port); |
| | | properties.setProperty("mail.imaps.host", server); |
| | | properties.setProperty("mail.imaps.port", port + ""); |
| | | } else if (protocol.contains("pop3")) {//接收协议pop3 |
| | | properties.put("mail.pop3.host", server); |
| | | properties.put("mail.pop3.port", port); |
| | | properties.setProperty("mail.pop3.host", server); |
| | | properties.setProperty("mail.pop3.port", port + ""); |
| | | } else {//其他(再加) |
| | | properties.put("mail.imaps.host", server); |
| | | properties.put("mail.imaps.port", port); |
| | | properties.setProperty("mail.imaps.host", server); |
| | | properties.setProperty("mail.imaps.port", port + ""); |
| | | } |
| | | // properties.put("mail.imaps.starttls.enable", "true");//// IMAP 协议设置 STARTTLS |
| | | |
| | |
| | | Properties properties = new Properties(); |
| | | properties.setProperty("mail.smtp.auth", "true");// // 设置SMTP是否需要认证 指定客户端是否向邮件服务器提交认证 |
| | | properties.setProperty("mail.transport.protocol", "smtp");//设置传输协议 指定采用的邮件发送协议。 |
| | | properties.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");// // 设置启用SSL加密 |
| | | properties.setProperty("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");// // 设置启用SSL加密 |
| | | properties.setProperty("mail.smtp.host", emailEntity.getSmtpHost()); |
| | | properties.setProperty("mail.smtp.port", emailEntity.getSmtpPort() + ""); |
| | | |
| | |
| | | MimeMessage message = new MimeMessage(session); |
| | | message.setFrom(new InternetAddress(sendEmail)); |
| | | message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail)); |
| | | message.setSubject(t482101H.getSubject()); |
| | | message.setSubject(t482101H.getSubject());//主题 |
| | | |
| | | String Unique_ID = "<onBus_" + UUID.randomUUID().toString().toUpperCase() + "@mail.com>";//系统单号唯一码 |
| | | message.setHeader("Message-ID", Unique_ID);//系统内部唯一码 |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer setQuickReply(String docCode, String content) throws MessagingException { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "declare @docCode varchar(200) ='" + docCode + "'\n"; |
| | | sql += "update t482101H set receive_time=getdate() where docCode=@docCode\n";//更新回复时间 |
| | | sql += "select a.subject,a.sender,a.receiver,a.messageid,b.smtpEmail,b.smtpPassword,b.smtpHost,b.smtpPort,isnull(b.smtpSSL,0) as smtpSSL " + |
| | | " from t482101H a join t482102 b on a.receiver=b.smtpEmail where docCode=@docCode"; |
| | | Map<String, Object> map = jdbcTemplate.queryForMap(sql); |
| | | if (map == null || map.get("sender") == null) { |
| | | throw new MessagingException("回复人信息查找不到,请检查docCode唯一码"); |
| | | } |
| | | String receiver = (String) map.get("sender");//收件人 |
| | | String sender = (String) map.get("receiver");//发件人 |
| | | String smtpSSL = map.get("smtpSSL").equals(0) ? "false" : "true"; |
| | | |
| | | Properties props = new Properties(); |
| | | props.setProperty("mail.smtp.auth", "true"); |
| | | props.setProperty("mail.transport.protocol", "smtp");//设置传输协议 指定采用的邮件发送协议。 |
| | | props.setProperty("mail.smtp.ssl.enable", smtpSSL);// // 设置启用SSL加密 |
| | | props.setProperty("mail.smtp.host", (String) map.get("smtpHost")); |
| | | props.setProperty("mail.smtp.port", map.get("smtpPort") + ""); |
| | | // props.setProperty("mail.smtp.starttls.enable", "true"); |
| | | |
| | | Session session = Session.getInstance(props, new javax.mail.Authenticator() { |
| | | protected PasswordAuthentication getPasswordAuthentication() { |
| | | return new PasswordAuthentication((String) map.get("smtpEmail"), (String) map.get("smtpPassword")); |
| | | } |
| | | }); |
| | | |
| | | Message replyMessage = new MimeMessage(session); |
| | | replyMessage.setFrom(new InternetAddress(sender)); |
| | | replyMessage.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver));//收件人 |
| | | replyMessage.setSubject("Re: " + map.get("subject"));//主题 |
| | | |
| | | // 引用原邮件 |
| | | replyMessage.setHeader("In-Reply-To", (String) map.get("messageid")); |
| | | replyMessage.setHeader("References", (String) map.get("messageid")); |
| | | |
| | | replyMessage.setText(content);//这里是回复的内容 |
| | | |
| | | Transport.send(replyMessage); |
| | | |
| | | return 1; |
| | | } catch (MessagingException e) { |
| | | throw new MessagingException("快速回复异常:" + e.getMessage()); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 收件箱返回的信息进行封装处理 |
| | | * |
| | |
| | | * @throws MessagingException |
| | | * @throws IOException |
| | | */ |
| | | public void setMailContent(Message[] messages, T482102Entity email, FoundationEntity foundation) throws Exception { |
| | | public void setMailContent(Message[] messages, T482102Entity email, FoundationEntity foundation) throws |
| | | Exception { |
| | | try { |
| | | List<t482101HEntity> t482101HEntityList = new ArrayList<>(); |
| | | List<String> messageIdList = mailIfc.getMessageIdList(email.getReceiveEmail());//存在系统表里的邮件 |
| | |
| | | * @throws Exception |
| | | */ |
| | | // 辅助方法,用于递归获取纯文本邮件内容 |
| | | private String getTextFromMimeMultipart(MimeMultipart mimeMultipart, StringBuilder plainText, List<MailFileEntity.MailBodyPart> part, String unId, StringBuilder attachment) throws Exception { |
| | | private String getTextFromMimeMultipart(MimeMultipart mimeMultipart, StringBuilder |
| | | plainText, List<MailFileEntity.MailBodyPart> part, String unId, StringBuilder attachment) throws Exception { |
| | | int count = mimeMultipart.getCount(); |
| | | if (count == 0) { |
| | | throw new MessagingException("Multipart with no body parts"); |
| | |
| | | String nextResult = result.toString(); |
| | | if (nextResult.contains(cId)) {//有嵌套内容 |
| | | //替换 |
| | | nextResult = nextResult.replace("cid:" + cId + "", shoppingImageServer + "/uploads/attachment/82/482101/" + unId + "@p@" + p.getPhysicalFile()); |
| | | nextResult = nextResult.replace("cid:" + cId + "", shoppingImageServer + "/mail/attachment/82/482101/" + unId + "@p@" + p.getPhysicalFile()); |
| | | result.setLength(0);//清空先 |
| | | result.append(nextResult); |
| | | } |