Explorar o código

邮件发送失败

jz.kai hai 1 ano
pai
achega
526cc251d8

+ 1 - 10
common/pom.xml

@@ -10,7 +10,7 @@
     <modelVersion>4.0.0</modelVersion>
     <artifactId>common</artifactId>
     <name>common</name>
-    <description>开发区网上入学系统公共库</description>
+    <description>订单系统公共库</description>
     <packaging>jar</packaging>
     <properties>
         <swagger2.version>2.7.0</swagger2.version>
@@ -148,15 +148,6 @@
         </dependency>
         <!-- 数据库相关 end-->
 
-        <!--短信相关 start-->
-        <dependency>
-            <groupId>com.taobao</groupId>
-            <artifactId>taobao-sdk-java</artifactId>
-            <version>1.0.0</version>
-        </dependency>
-        <!--短信相关 end-->
-
-
         <!-- aliyun oss start -->
         <dependency>
             <groupId>com.aliyun.oss</groupId>

+ 0 - 155
common/src/main/java/com/jpsoft/order/modules/common/utils/SMSUtil.java

@@ -1,155 +0,0 @@
-package com.jpsoft.order.modules.common.utils;
-
-import com.jpsoft.order.modules.common.dto.MessageResult;
-import com.taobao.api.ApiException;
-import com.taobao.api.DefaultTaobaoClient;
-import com.taobao.api.TaobaoClient;
-import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
-import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;
-import net.sf.json.JSONException;
-import net.sf.json.JSONObject;
-
-import java.util.Random;
-
-
-public class SMSUtil {
-	
-	public final static String REG_TEMPLATE_CODE = "SMS_49390047";
-	public static final String NUMBERCHAR = "0123456789";
-	
-	private final static String APP_KEY = "24698874";
-	private final static String APP_SECRET = "5f5b21d1dc93e124aa803f95d71c00b8";
-	private final static String APP_URL = "https://eco.taobao.com/router/rest";
-	private final static String SIGN_NAME = "荆鹏云平台";
-	private final static String SMS_TYPE = "normal";
-	
-	/**
-	 * 
-	 * @param phones 手机号,多个以英文逗号","隔开
-	 * @param smsTemplateCode 短信模版ID
-	 * @param jsonStr 短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开。示例:针对模板“验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”,传参时需传入{"code":"1234","product":"alidayu"}
-	 * @return
-	 */
-	public static MessageResult send(String phones, String smsTemplateCode, String jsonStr){
-		
-		boolean success = true;
-		String msg = "发送成功";
-		
-		TaobaoClient client = new DefaultTaobaoClient(APP_URL, APP_KEY, APP_SECRET);
-		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
-		req.setSmsType(SMS_TYPE);
-		req.setSmsFreeSignName(SIGN_NAME);
-		if(jsonStr != null){
-			req.setSmsParamString(jsonStr);
-		}
-		req.setRecNum(phones);
-		req.setSmsTemplateCode(smsTemplateCode);
-		AlibabaAliqinFcSmsNumSendResponse rsp;
-		try {
-			rsp = client.execute(req);
-			
-			JSONObject ret = JSONObject.fromObject(rsp.getBody());
-			
-			System.out.println("ret>>>>" + ret);
-			
-			if(ret.containsKey("error_response")){
-				success = false;
-				msg = ret.getJSONObject("error_response").getString("sub_msg");
-			}else if(ret.containsKey("alibaba_aliqin_fc_sms_num_send_response")){
-				
-				JSONObject result = ret.getJSONObject("alibaba_aliqin_fc_sms_num_send_response").getJSONObject("result");
-				
-				if(!result.getBoolean("success")){
-					msg = result.getString("msg");
-				}
-			}else{
-				success = false;
-				msg = ret.toString();
-			}
-		} catch (ApiException e) {
-			success = false;
-			msg = e.getErrMsg();
-		} catch (JSONException ex) {
-			success = false;
-			msg = ex.getMessage();
-		}
-
-		MessageResult retMessage = new MessageResult();
-		
-		retMessage.setMessage(msg);
-		retMessage.setResult(success);
-		
-		return retMessage;
-	}
-	
-	/**
-	 * 
-	 * @param phones 手机号,多个以英文逗号","隔开
-	 * @param signName 签名:目前仅支持"荆鹏云平台","速乐购"两种签名
-	 * @param smsTemplateCode 短信模版ID
-	 * @param json 短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开。示例:针对模板“验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”,传参时需传入{"code":"1234","product":"alidayu"}
-	 * @return
-	 */
-	public static MessageResult send(String phones, String signName, String smsTemplateCode, JSONObject json){
-		
-		boolean success = true;
-		String msg = "发送成功";
-		
-		TaobaoClient client = new DefaultTaobaoClient(APP_URL, APP_KEY, APP_SECRET);
-		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
-		req.setSmsType(SMS_TYPE);
-		req.setSmsFreeSignName(signName);
-		if(json != null){
-			req.setSmsParamString(json.toString());
-		}
-		req.setRecNum(phones);
-		req.setSmsTemplateCode(smsTemplateCode);
-		AlibabaAliqinFcSmsNumSendResponse rsp;
-		try {
-			rsp = client.execute(req);
-			
-			JSONObject ret = JSONObject.fromObject(rsp.getBody());
-			
-			System.out.println("ret>>>>" + ret);
-			
-			if(ret.containsKey("error_response")){
-				success = false;
-				msg = ret.getJSONObject("error_response").getString("sub_msg");
-			}else if(ret.containsKey("alibaba_aliqin_fc_sms_num_send_response")){
-				
-				JSONObject result = ret.getJSONObject("alibaba_aliqin_fc_sms_num_send_response").getJSONObject("result");
-				
-				if(!result.getBoolean("success")){
-					msg = result.getString("msg");
-				}
-			}else{
-				success = false;
-				msg = ret.toString();
-			}
-		} catch (ApiException e) {
-			success = false;
-			msg = e.getErrMsg();
-		} catch (JSONException ex) {
-			success = false;
-			msg = ex.getMessage();
-		}
-
-		MessageResult retMessage = new MessageResult();
-		
-		retMessage.setMessage(msg);
-		retMessage.setResult(success);
-		
-		return retMessage;
-	}
-
-
-
-	public static String generateNumberString(int length) {
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < length; i++) {
-			sb.append(NUMBERCHAR.charAt(random.nextInt(NUMBERCHAR.length())));
-		}
-		return sb.toString();
-	}
-}

+ 1 - 1
web/pom.xml

@@ -12,7 +12,7 @@
     <version>1.0.0</version>
     <name>web</name>
     <packaging>war</packaging>
-    <description>开发区网上入学系统网站</description>
+    <description>订单系统网站</description>
     <properties>
         <swagger2.version>2.7.0</swagger2.version>
         <jwts.version>0.10.5</jwts.version>

+ 2 - 1
web/src/main/java/com/jpsoft/order/modules/common/controller/sendEmailController.java

@@ -25,11 +25,12 @@ public class sendEmailController {
             sf.setTrustAllHosts(true);
             prop.put("mail.smtp.ssl.enable", "true");
             prop.put("mail.smtp.ssl.socketFactory", sf);
+            prop.put("mail.smtp.ssl.protocols", "TLSv1.2");
 
             //1、创建定义整个应用程序所需的环境信息的 Session 对象
             Session session = Session.getDefaultInstance(prop, new Authenticator() {
                 public PasswordAuthentication getPasswordAuthentication() {
-                    return new PasswordAuthentication("it@feilihua.com", "wtXLHBFWTEo3qSkn");//发件人邮件用户名、授权码
+                    return new PasswordAuthentication("it@feilihua.com", "Ba1234");//发件人邮件用户名、授权码
                 }
             });
             session.setDebug(true);//开启Session的debug模式,这样就可以查看到程序发送Email的运行状态