邮箱服务
parent
965b0809ce
commit
4dc393189b
|
|
@ -113,10 +113,6 @@
|
|||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.common.core.utils.mail;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.FileDataSource;
|
||||
|
|
@ -16,8 +19,7 @@ import javax.mail.internet.MimeBodyPart;
|
|||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
public class ALiYunMailUtil {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
package com.ruoyi.common.core.utils.mail;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
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.qiye.aliyun.com";
|
||||
private static final String PORT = "25"; // 或80
|
||||
private static final String SUBJECT = "Email verification code";
|
||||
private static final String FILE_PATH = null;
|
||||
private static final String CC = null;
|
||||
|
||||
/**
|
||||
* @param content 邮件内容
|
||||
* @param internetAddress 收件人地址
|
||||
* @throws Exception
|
||||
* @throws AddressException
|
||||
*/
|
||||
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";
|
||||
Properties props = System.getProperties();
|
||||
props.setProperty("mail.smtp.host", HOST);
|
||||
// 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");
|
||||
|
||||
// 建立邮件会话
|
||||
Session session = Session.getDefaultInstance(props, new Authenticator() { // 身份认证
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(SEND_ADDRESS, SEND_PASSWORD); // 发件人账号、密码
|
||||
}
|
||||
});
|
||||
|
||||
// 建立邮件对象
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
|
||||
// 设置邮件的发件人、收件人、主题
|
||||
message.setFrom(new InternetAddress(SEND_ADDRESS)); // 发件人账号
|
||||
message.setRecipients(Message.RecipientType.TO, internetAddress); // 收件人账号
|
||||
|
||||
// 标题
|
||||
message.setSubject(SUBJECT); // 邮件标题
|
||||
|
||||
// 内容
|
||||
Multipart multipart = new MimeMultipart();
|
||||
BodyPart contentPart = new MimeBodyPart();
|
||||
// 将内容包装在HTML样式标签中,调整字体粗细
|
||||
String styledContent = "<html><body><p style='font-weight: normal;'>"
|
||||
+ content
|
||||
+ "</p></body></html>";
|
||||
contentPart.setContent(styledContent, "text/html;charset=utf-8"); // 邮件内容
|
||||
multipart.addBodyPart(contentPart);
|
||||
|
||||
// 附件部分
|
||||
if (StringUtils.isNotBlank(FILE_PATH)) {
|
||||
BodyPart attachPart = new MimeBodyPart();
|
||||
FileDataSource fileDataSource = new FileDataSource(FILE_PATH); // 附件地址 D:/题库上传模板v1.xlsx
|
||||
attachPart.setDataHandler(new DataHandler(fileDataSource));
|
||||
attachPart.setFileName(MimeUtility.encodeText(fileDataSource.getName()));
|
||||
multipart.addBodyPart(attachPart);
|
||||
}
|
||||
|
||||
message.setContent(multipart);
|
||||
|
||||
// 抄送地址
|
||||
if (StringUtils.isNotBlank(CC)) {
|
||||
InternetAddress[] internetAddressCC = new InternetAddress().parse(CC);
|
||||
message.setRecipients(Message.RecipientType.CC, internetAddressCC);
|
||||
}
|
||||
|
||||
// 发送邮件
|
||||
Transport.send(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package com.ruoyi.common.core.utils.mail;
|
||||
|
||||
public class EmailService {
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import com.ruoyi.common.core.utils.DateUtils;
|
|||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||
import com.ruoyi.common.core.utils.mail.ALiYunMailUtil;
|
||||
import com.ruoyi.common.core.utils.mail.AliMailUtil;
|
||||
import com.ruoyi.common.core.utils.mail.MailUtil;
|
||||
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
|
@ -230,7 +231,7 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
|||
+ "<p>http://127.0.0.1:9204/app/activation/" + token + "/" + email + "</p>"
|
||||
+ "</body></html>";
|
||||
try {
|
||||
ALiYunMailUtil.sendMail(EM, email);
|
||||
AliMailUtil.sendMail(EM, email);
|
||||
} catch (MessagingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,14 @@ public class AlipayConstant {
|
|||
|
||||
public static final String SUBJECT = "订单充值";
|
||||
|
||||
public static final String CERT_PATH = "/opt/jar/gan/cert/appCertPublicKey_2021004144677656.crt";
|
||||
// public static final String CERT_PATH = "/opt/jar/gan/cert/appCertPublicKey_2021004144677656.crt";
|
||||
public static final String CERT_PATH = "/Users/wyh/Documents/证书20240524173546/appCertPublicKey_2021004144677656.crt";
|
||||
|
||||
public static final String ALIPAY_PUBLIC_CERT_PATH = "/opt/jar/gan/cert/alipayCertPublicKey_RSA2.crt";
|
||||
// public static final String ALIPAY_PUBLIC_CERT_PATH = "/opt/jar/gan/cert/alipayCertPublicKey_RSA2.crt";
|
||||
public static final String ALIPAY_PUBLIC_CERT_PATH = "/Users/wyh/Documents/证书20240524173546/alipayCertPublicKey_RSA2.crt";
|
||||
|
||||
public static final String ROOT_CERT_PATH = "/opt/jar/gan/cert/alipayRootCert.crt";
|
||||
// public static final String ROOT_CERT_PATH = "/opt/jar/gan/cert/alipayRootCert.crt";
|
||||
public static final String ROOT_CERT_PATH = "/Users/wyh/Documents/证书20240524173546/alipayRootCert.crt";
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="是否为会员" align="center" prop="isMember" >
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.sex == 0 ? '是' : scope.row.sex == 1 ? '否' : '未知' }}
|
||||
{{ scope.row.isMember == 0 ? '是' : scope.row.isMember == 1 ? '否' : '未知' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="电话" align="center" prop="phone" />
|
||||
|
|
@ -119,58 +119,6 @@
|
|||
<el-table-column label="学校" align="center" prop="schoolName" />
|
||||
<el-table-column label="学历" align="center" prop="education" />
|
||||
<el-table-column label="专业" align="center" prop="major" />
|
||||
<!-- <el-table-column label="学历开始时间" align="center" prop="startTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="学历结束时间" align="center" prop="endTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="在校经历" align="center" prop="experience" />-->
|
||||
<!-- <el-table-column label="公司名称" align="center" prop="companyName" />-->
|
||||
<!-- <el-table-column label="行业" align="center" prop="industry" />-->
|
||||
<!-- <el-table-column label="在职时间" align="center" prop="jobTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.jobTime, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="职位名称" align="center" prop="jobName" />-->
|
||||
<!-- <el-table-column label="职位类别" align="center" prop="jobType" />-->
|
||||
<!-- <el-table-column label="技能id" align="center" prop="skillId" />-->
|
||||
<!-- <el-table-column label="工作内容" align="center" prop="jobContent" />-->
|
||||
<!-- <el-table-column label="权限:0公开1私密" align="center" prop="type" />-->
|
||||
<!-- <el-table-column label="性别" align="center" prop="sex" >-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- {{ scope.row.sex == 0 ? '男' : scope.row.sex == 1 ? '女' : '未知' }}-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="出生年月" align="center" prop="birthday" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="共享资源" align="center" prop="shareResource" />-->
|
||||
<!-- <el-table-column label="是否是技术人员,0是1否" align="center" prop="isTech" />-->
|
||||
<!-- <el-table-column label="创业想法" align="center" prop="idea" />-->
|
||||
<!-- <el-table-column label="是否是合伙人,0是1否" align="center" prop="isPartner" />-->
|
||||
<!-- <el-table-column label="业余爱好" align="center" prop="hobby" />-->
|
||||
<!-- <el-table-column label="生活城市" align="center" prop="city" />-->
|
||||
<!-- <el-table-column label="其他信息" align="center" prop="other" />-->
|
||||
<!-- <el-table-column label="是否是会员0是1否" align="center" prop="isMember" />-->
|
||||
<!-- <el-table-column label="订单记录" align="center" prop="orderId" />-->
|
||||
<!-- <el-table-column label="开始时间" align="center" prop="orderStartTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.orderStartTime, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="结束时间" align="center" prop="orderEndTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.orderEndTime, '{y}-{m}-{d}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="200">
|
||||
<template slot-scope="scope">
|
||||
|
||||
|
|
|
|||
|
|
@ -602,4 +602,4 @@ export default {
|
|||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue