bug修改
parent
b01bbb168e
commit
af1ebcbc4f
|
|
@ -2,6 +2,7 @@ package com.ruoyi.common.core.utils.mail;
|
|||
|
||||
|
||||
|
||||
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
|
@ -26,7 +27,7 @@ public class AliMailUtil {
|
|||
private static final String SEND_ADDRESS = "mail@gbgobig.com";
|
||||
private static final String SEND_PASSWORD = "ganbeigobig@2024";
|
||||
private static final String HOST = "smtp.mxhichina.com";
|
||||
private static final String PORT = "25"; // 或80
|
||||
private static final String PORT = "456"; // 或80
|
||||
private static final String SUBJECT = "Email verification code";
|
||||
private static final String FILE_PATH = null;
|
||||
private static final String CC = null;
|
||||
|
|
@ -40,16 +41,17 @@ public class AliMailUtil {
|
|||
public static void sendMail(String content, String internetAddress) throws AddressException, Exception {
|
||||
// 设置SSL连接、邮件环境
|
||||
// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||
// final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||
Properties props = System.getProperties();
|
||||
props.setProperty("mail.smtp.host", HOST);
|
||||
// props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
|
||||
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
|
||||
props.setProperty("mail.smtp.socketFactory.fallback", "false");
|
||||
props.setProperty("mail.smtp.port", PORT); // 设置端口
|
||||
props.setProperty("mail.debug", "true"); // 启用调试
|
||||
props.setProperty("mail.smtp.socketFactory.port", "465");
|
||||
props.setProperty("mail.smtp.auth", "true");
|
||||
|
||||
//props.put("mail.smtp.timeout", "10000"); // 设置超时时间为10秒
|
||||
|
||||
// 建立邮件会话
|
||||
Session session = Session.getDefaultInstance(props, new Authenticator() { // 身份认证
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
|
|
@ -97,4 +99,13 @@ public class AliMailUtil {
|
|||
// 发送邮件
|
||||
Transport.send(message);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
String uuid = IdUtils.fastUUID();
|
||||
String EM = "<html><body><h2>欢迎来到我们的服务!!</h2>"
|
||||
+ "<p>请点击下面的网址确认您的注册:</p>"
|
||||
+ "<a href=https://gobig.flameby.com/api/app/activation/" + uuid + "/2922936090@qq.com>注册账号</a>"
|
||||
+ "</body></html>";
|
||||
sendMail(EM,"2922936090@qq.com");
|
||||
}
|
||||
}
|
||||
|
|
@ -74,8 +74,9 @@ public class AppLoginController {
|
|||
private AppRegisterMapper appRegisterMapper;
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "2@qq.com";
|
||||
System.out.println(IdUtils.fastUUID());
|
||||
String email = "ddd@qq.com";
|
||||
String emailStr = email.substring(email.indexOf("@") + 1,email.length());
|
||||
System.out.println(emailStr);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
|
|
@ -112,14 +113,17 @@ public class AppLoginController {
|
|||
}
|
||||
String uuid = IdUtils.fastUUID();
|
||||
redisService.setCacheObject(uuid, registerForm);
|
||||
log.info("发送前---------------");
|
||||
try {
|
||||
String EM = "<html><body><h2>欢迎来到我们的服务!!</h2>"
|
||||
+ "<p>请点击下面的网址确认您的注册:</p>"
|
||||
+ "<a href=https://gobig.flameby.com/api/app/activation/" + uuid + "/" + registerForm.getEmail() + ">注册账号</a>"
|
||||
+ "</body></html>";
|
||||
log.info("发送前---------------" + registerForm.getEmail());
|
||||
AliMailUtil.sendMail(EM,registerForm.getEmail());
|
||||
log.info("邮箱发送成功-------------------");
|
||||
} catch (Exception e) {
|
||||
log.info("发送后---------------" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue