From 28eb26d68f7a2a4e6b316c3ea9f511aa143db66e Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 30 Sep 2024 16:57:18 +0800
Subject: [PATCH] 55测试环境
---
src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java | 75 ++++++++++++++++++++++++++++---------
1 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java b/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java
index 0ba66e9..3c1b926 100644
--- a/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java
+++ b/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java
@@ -1,6 +1,8 @@
package com.xcong.excoin.utils.mail;
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -15,6 +17,7 @@
import org.apache.http.util.EntityUtils;
import java.io.IOException;
+import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
@@ -38,24 +41,60 @@
public static final String TYPE_MD5 = "md5";
public static final String TYPE_SHA1 = "sha1";
+ private static final String APP_ID = "16082";
+ private static final String APP_KEY = "f34c792a1112c16c190ed7190d386c4f";
+ private static final String FROM = "goldenFlame@submail.goldflame.cc";
+ private static final String SIGN_TYPE = "";
+
+ /**
+ * 发送验证码邮件
+ *
+ * @param to 对象
+ * @param code 验证码
+ * @return true or false
+ */
public static boolean sendMail(String to, String code) {
- TreeMap<String, Object> requestData = new TreeMap<String, Object>();
JSONObject vars = new JSONObject();
vars.put("code", code);
- String appid = "16082";
- String appkey = "f34c792a1112c16c190ed7190d386c4f";
- String project = "fMBQk1";
- String signtype = "";
- String from = "ex@submail.excoin.site";
+ String project = "qNv3f4";
+ return request(vars, project, to);
+ }
- requestData.put("appid", appid);
+ /**
+ * 发送充值成功邮件
+ *
+ * @param to 对象
+ * @param time 成功时间
+ * @param orderNo 订单编号
+ * @return true or false
+ */
+ public static boolean sendRechargeMail(String to, String time, String orderNo) {
+ JSONObject vars = new JSONObject();
+ vars.put("time", time);
+ vars.put("orderNo", orderNo);
+ String project = "6dH3j";
+ return request(vars, project, to);
+ }
+
+ public static boolean sendWithdrawalMail(String to, String time) {
+ JSONObject vars = new JSONObject();
+ vars.put("time", time);
+ String project = "Vyk0y2";
+ return request(vars, project, to);
+ }
+
+
+ private static boolean request(JSONObject vars, String project, String to) {
+ TreeMap<String, Object> requestData = new TreeMap<String, Object>();
+ requestData.put("appid", APP_ID);
requestData.put("project", project);
requestData.put("to", to);
- requestData.put("from", from);
+ requestData.put("from", FROM);
if (!vars.isEmpty()) {
requestData.put("vars", vars.toString());
}
+
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
@SuppressWarnings("deprecation")
ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
@@ -66,17 +105,17 @@
builder.addTextBody(key, String.valueOf(value), contentType);
}
}
- if (signtype.equals(TYPE_MD5) || signtype.equals(TYPE_SHA1)) {
+ if (SIGN_TYPE.equals(TYPE_MD5) || SIGN_TYPE.equals(TYPE_SHA1)) {
String timestamp = getTimestamp();
requestData.put("timestamp", timestamp);
- requestData.put("sign_type", signtype);
- String signStr = appid + appkey + RequestEncoder.formatRequest(requestData) + appid + appkey;
+ requestData.put("sign_type", SIGN_TYPE);
+ String signStr = APP_ID + APP_KEY + RequestEncoder.formatRequest(requestData) + APP_ID + APP_KEY;
builder.addTextBody("timestamp", timestamp);
- builder.addTextBody("sign_type", signtype);
- builder.addTextBody("signature", RequestEncoder.encode(signtype, signStr), contentType);
+ builder.addTextBody("sign_type", SIGN_TYPE);
+ builder.addTextBody("signature", RequestEncoder.encode(SIGN_TYPE, signStr), contentType);
} else {
- builder.addTextBody("signature", appkey, contentType);
+ builder.addTextBody("signature", APP_KEY, contentType);
}
HttpPost httpPost = new HttpPost(URL);
@@ -92,8 +131,6 @@
return true;
}
}
- } catch (ClientProtocolException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
@@ -118,8 +155,6 @@
return json.getString("timestamp");
}
closeableHttpClient.close();
- } catch (ClientProtocolException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
@@ -128,6 +163,8 @@
}
public static void main(String[] args) {
- System.out.println(sendMail("123@123.com", "123456"));
+// System.out.println(sendMail("546766039@qq.com", "123456"));
+
+ System.out.println(sendRechargeMail("512061637@qq.com", "wewewewe","123456"));
}
}
--
Gitblit v1.9.1