添加邮箱服务器类型标记
This commit is contained in:
parent
1c4b4af39c
commit
2d96fbe7d0
|
@ -21,6 +21,7 @@ import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.mail.*;
|
import javax.mail.*;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
@ -56,13 +57,21 @@ public class EmailServiceManager {
|
||||||
* 系统启动时间
|
* 系统启动时间
|
||||||
*/
|
*/
|
||||||
private Date systemStartupTime;
|
private Date systemStartupTime;
|
||||||
/** 邮件接收数量 */
|
/**
|
||||||
|
* 邮件接收数量
|
||||||
|
*/
|
||||||
private Integer receiveNum;
|
private Integer receiveNum;
|
||||||
/** smtp协议的存储对象 */
|
/**
|
||||||
|
* smtp协议的存储对象
|
||||||
|
*/
|
||||||
private IMAPStore store = null;
|
private IMAPStore store = null;
|
||||||
/** 邮件附件临时存储路径 */
|
/**
|
||||||
|
* 邮件附件临时存储路径
|
||||||
|
*/
|
||||||
private String temporaryStoragePath;
|
private String temporaryStoragePath;
|
||||||
/** 收件箱 */
|
/**
|
||||||
|
* 收件箱
|
||||||
|
*/
|
||||||
private Folder folder = null;
|
private Folder folder = null;
|
||||||
|
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
@ -78,6 +87,7 @@ public class EmailServiceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化邮件服务管理器
|
* 初始化邮件服务管理器
|
||||||
|
*
|
||||||
* @param email 邮件属性
|
* @param email 邮件属性
|
||||||
*/
|
*/
|
||||||
public void init(SysEmail email) {
|
public void init(SysEmail email) {
|
||||||
|
@ -86,6 +96,7 @@ public class EmailServiceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化邮件服务管理器
|
* 初始化邮件服务管理器
|
||||||
|
*
|
||||||
* @param email 邮件属性
|
* @param email 邮件属性
|
||||||
*/
|
*/
|
||||||
public void init(SysEmail email, Integer receiveNum, String temporaryStoragePath,
|
public void init(SysEmail email, Integer receiveNum, String temporaryStoragePath,
|
||||||
|
@ -158,8 +169,12 @@ public class EmailServiceManager {
|
||||||
store = (IMAPStore) session.getStore();
|
store = (IMAPStore) session.getStore();
|
||||||
//连接
|
//连接
|
||||||
store.connect(email.getUsername(), email.getPassword());
|
store.connect(email.getUsername(), email.getPassword());
|
||||||
|
if (email.getEmailServerType()==1) {
|
||||||
|
|
||||||
// 解决163普通邮箱无法建立连接问题
|
// 解决163普通邮箱无法建立连接问题
|
||||||
store.id(IAM);
|
store.id(IAM);
|
||||||
|
}
|
||||||
|
|
||||||
//获取收件箱
|
//获取收件箱
|
||||||
folder = store.getFolder("INBOX");//INBOX
|
folder = store.getFolder("INBOX");//INBOX
|
||||||
folder.open(Folder.READ_WRITE);
|
folder.open(Folder.READ_WRITE);
|
||||||
|
@ -446,6 +461,7 @@ public class EmailServiceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取邮件主题
|
* 获取邮件主题
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -468,6 +484,7 @@ public class EmailServiceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取邮件内容
|
* 获取邮件内容
|
||||||
|
*
|
||||||
* @param part
|
* @param part
|
||||||
* @return
|
* @return
|
||||||
* @throws MessagingException
|
* @throws MessagingException
|
||||||
|
@ -487,6 +504,7 @@ public class EmailServiceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存邮件附件
|
* 保存邮件附件
|
||||||
|
*
|
||||||
* @param part
|
* @param part
|
||||||
* @throws MessagingException
|
* @throws MessagingException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -713,8 +731,10 @@ public class EmailServiceManager {
|
||||||
public void a(AtomicReference<FileOutputStream> outputStream, Message message) throws MessagingException, IOException {
|
public void a(AtomicReference<FileOutputStream> outputStream, Message message) throws MessagingException, IOException {
|
||||||
message.writeTo(outputStream.get());
|
message.writeTo(outputStream.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除邮件
|
* 删除邮件
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @throws MessagingException
|
* @throws MessagingException
|
||||||
*/
|
*/
|
||||||
|
@ -768,6 +788,7 @@ public class EmailServiceManager {
|
||||||
/**
|
/**
|
||||||
* 校验邮件
|
* 校验邮件
|
||||||
* 若此次获取的邮件是上次删除失败的邮件直接删除
|
* 若此次获取的邮件是上次删除失败的邮件直接删除
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public boolean check(Message message, String messageId) {
|
public boolean check(Message message, String messageId) {
|
||||||
|
|
|
@ -94,4 +94,6 @@ public class SysEmail implements Serializable {
|
||||||
*/
|
*/
|
||||||
@TableField(value = "update_by")
|
@TableField(value = "update_by")
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
@TableField(value = "email_server_type")
|
||||||
|
private Integer emailServerType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user