package com.jack.platformweb.email.service;
import com.sun.mail.imap.IMAPStore;
import com.jack.common.redis.service.RedisService;
import com.jack.common.utils.DateUtils;
import com.jack.common.utils.JsonUtils;
import com.jack.common.utils.ZipUtils;
import com.jack.db.urgerobot.robot.model.RobotInfo;
import com.jack.platformweb.partner.service.GzOutUrgeFileService;
import com.jack.platformweb.robot.service.RobotInfoService;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeUtility;
import javax.print.DocFlavor;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description
* @Author zhenghao
* @Date 2021/8/17 22:07
**/
@Service
public class RemoteEmailService {
private static Logger log = LoggerFactory.getLogger(RemoteEmailService.class);
@Value("${gz.local.path}")
private String attachFilePath;
@Autowired
private GzOutUrgeFileService gzOutUrgeFileService;
@Autowired
private RobotInfoService robotInfoService;
@Autowired
private RedisService redisService;
//从哪个邮箱地址获取内容
private static String username = "test@qq.com";
private static String password = "123456";
private static Integer robotId = 161;
//过滤发件人
private static List<String> monitoringEmail = Stream.of("tt@qq.com").collect(Collectors.toList());
private IMAPStore getConnect() {
log.info("开始获得邮件链接");
// 准备连接服务器的会话信息
IMAPStore store = null;
try {
Properties props = new Properties();
// props.setProperty("mail.store.protocol", "imap");
// props.setProperty("mail.imap.host", "imap.exmail.qq.com");
// props.setProperty("mail.imap.port", "993");
// props.setProperty("mail.imap.ssl.enable", "true");
//
// props.setProperty("mail.imap.auth.plain.disable", "true");
//
// Session session = Session.getInstance(props, new javax.mail.Authenticator() {
// @Override
//
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(username, password
//
// );
//
// }
//
// });
props.put("mail.imap.host", "imap.exmail.qq.com");//QQ邮箱为:imap.qq.com
props.put("mail.imap.auth", "true");
props.setProperty("mail.st
java从腾讯邮箱获得文件
最新推荐文章于 2024-04-28 10:54:51 发布