网友马宝强分享:
吧里老哥的教程http://www.zuanke8.com/thread-6308988-1-1.html
企业微信同步微信需要企业认证,微信企业还要下载客户端,耐何过不了这关,so增加个邮件转发的,速度比微信企业慢。
优化了一下验证码提取,用的是这个网站的代转发邮件接口https://www.smtpjs.com/,担心安全的自己建邮件转发服务器吧
163邮箱开启smpt服务获取密码
实现步骤 https://www.jianshu.com/p/d7842a82cb13
代码改为下面的
- //下面的三个变量值需要修改
- var ID = "wwce7d15ef385ec4e2";
- var SECRET = "NslLpnGvXXL6EThGn1OYgYRtVwU2MoAwUKSx6SlJ7RE";
- var AGENTID = "1000002";
- //定义post方法
- function posthttp(url, data) {
- var xhr = new XMLHttpRequest();
- xhr.addEventListener("readystatechange", function () {
- if (this.readyState === 4) {
- flash(this.responseText); //显示返回消息,可删除本行
- }
- });
- xhr.open("POST", url, false);
- xhr.send(data);
- return xhr.responseText;
- }
- //定义get方法
- function gethttp(url) {
- var xhr = new XMLHttpRequest();
- xhr.addEventListener("readystatechange", function () {
- if (this.readyState === 4) {
- flash(this.responseText); //显示返回消息,可删除本行
- }
- });
- xhr.open("GET", url, false);
- xhr.send();
- return xhr.responseText;
- }
- //获取token
- var gettoken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + ID + "&corpsecret=" + SECRET;
- var ACCESS_TOKEN = JSON.parse(gethttp(gettoken)).access_token;
- //发送消息(文本)
- var SMSRF = global(‘SMSRF’);
- var SMSRB = global(‘SMSRB’);
- var SMSRT = global(‘SMSRT’);
- var SMSRD = global(‘SMSRD’);
- var YZM = SMSRF;
- var TXT = SMSRB.match(/[0-9]{6}/g);
- if(TXT===null){
- TXT = SMSRB.match(/[0-9]{4}/g);
- if(TXT===null){
- var YZM = "无验证码";
- };
- };
- var YZM = TXT[0];
- var CONTENT = "码:"+YZM+"发件人: " + SMSRF + "\n时间: " + SMSRT + ", 日期: " + SMSRD + "\n短信内容: " + SMSRB;
- //设置参数
- var message = JSON.stringify({
- "touser": "@all",
- "msgtype": "text",
- "agentid": AGENTID,
- "text": {
- "content": CONTENT
- },
- "safe": 0
- });
- var send = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + ACCESS_TOKEN;
- posthttp(send, message);
- //发送消息(邮箱)
- var message1 = JSON.stringify({
- "Host":"smtp.163.com",
- "Username":"*******@163.com",//始发邮箱
- "Password":"********",//开启smpt的密码
- "To":"*****@qq.com",//转发邮箱
- "From":"****@163.com",//始发邮箱
- "Subject":"码:"+YZM,
- "Body":CONTENT,
- "nocache":1,
- "Action":"Send"
- });
- var send1 = "https://smtpjs.com/v3/smtpjs.aspx?";
- posthttp(send1, message1);
复制代码