需求阐述

在写完定时任务发送邮件之后,调试的时候发现报错:Could not connect to SMTP host:smtp.exmail.qq.com,port:465。一开始我以为是在for循环里发送邮件导致的,把循环禁用掉之后,发现还是这个报错。说明不是for循环的问题。之前定时任务发送邮件没问题,只有我写的这个定时任务循环发送邮件报这个错。

解决方式

在设置发送邮件的邮件服务器的属性时,添加这样一行代码:

props.put(“mail.smtp.ssl.protocols”, “TLSv1.2”);
    public getEmailSession(final String host, final String port, final String username, final String password) {this.host = host;this.username = username;this.password = password;this.port = port;Properties props = null;props = new Properties();// 设置发送邮件的邮件服务器的属性props.put("mail.transport.protocol", "smtp");props.put("mail.smtp.host", host);props.put("mail.smtp.auth", "true");props.put("mail.smtp.port", port);props.put("mail.smtp.ssl.enable", "true");**props.put("mail.smtp.ssl.protocols", "TLSv1.2");**session = Session.getDefaultInstance(props, new Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(username, password);}});}

写定时任务发送邮件报错(Could not connect to SMTP host:smtp.exmail.qq.com,port:465)相关推荐

  1. 线上发送邮件问题记录(Could not connect to SMTP host:smtp.exmail.qq.com,port:465)

    事件回顾到某天下班,然后听到手机消息,来自企业微信,是财务小姐姐向我发来了问候,问我为什么邮件突然就发不出去了. 我也愣住了,这个功能是去年做的了,一直没有什么问题,甚至另一个系统也是copy我的代码 ...

  2. SpringBoot发送邮件报错:Got bad greeting from SMTP host: smtp.exmail.qq.com, port: 465, response: [EOF]

    错误 Got bad greeting from SMTP host: smtp.exmail.qq.com, port: 465, response: [EOF] 原配置: spring:mail: ...

  3. 发邮件报Failed to send email: Could not connect to SMTP host: smtp.exmail.qq.com, port: 465, response:-1

    我这里使用的是腾讯企业邮箱,原先设置的邮箱端口号是465,使用脚本自动发送邮件时,每次都报端口错误,经过,网上各种查找,将465换成了587,再次运行,即可成功:

  4. JAVA服务器端发送邮件问题:Could not connect to SMTP host: smtp.qq.com, port: 465

    前言 在开发过程中,发送邮件经过测试是没有问题,然后部署到服务器中(腾讯云服务器),发送邮件一直报Could not connect to SMTP host: smtp.qq.com, port: ...

  5. 使用hutool-all进行邮件发送报错Could not connect to SMTP host: smtp.qq.com, port: 465

    继承MailAccount类,在其中的getSmtpProps()方法中添加 props.put("mail.smtp.ssl.protocols", "TLSv1.2& ...

  6. 使用mail发送邮件 报错找不到服务器Could not connect to SMTP host: smtp.***.com, port: 465, response: -1

    使用mail发送邮件 报错找不到服务器 /*** 背景* 在使用javamail进行邮件发送的时候,报错:* Could not connect to SMTP host: smtp.***.com, ...

  7. java发送邮件报错554_java发送邮件报错554

    报错信息如下: com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM 163 smtp7,C8CowADX52cFukxeCH3ABQ--.249 ...

  8. 发送自动邮件时Could not connect to SMTP host: 10.1.1.195, port: 25;报错的解决方法

    最近在测试公司内部系统自动发送邮件功能时,一直在报错: javax.mail.SendFailedException: Sending failed;nested exception is: java ...

  9. oracle 10035 err 942,案例:Oracle日志报错 Fatal NI connect error 12170 TNS-12535 TNS-00505

    天萃荷净 Oracle数据库alert日志文件报错Fatal NI connect error 12170,通过查看mos相关文章找到解决办法 今天在一台服务器的日志文件中,发现如下信息: Fatal ...

最新文章

  1. 一个虚函数和虚继承的问题。
  2. arm服务器配置信息,ARM板 web服务器交叉编译及配置
  3. 国产最大AI开源框架再升级:一口气发布9大新产品,顺便送出亿元GPU算力
  4. 第04章—整合Mybatis
  5. Linux进程间通信一 System V 共享内存简介与示例
  6. robot:当用例失败时执行关键字(发送短信)
  7. ajax,jsonp,axios面试题
  8. /usr/bin/python^M: bad interpreter: No such file or directory
  9. 为啥加班多太多对身体会造成影响,不干活就不会对身体造成影响么?
  10. 腾讯与老干妈达成和解;传苹果将停掉 MacBook Air 产品线;VS Code 1.47 发布| 极客头条...
  11. java虚拟机工作原理_Java虚拟机工作原理详解
  12. Linux 下安装JDK1.8
  13. 链接器工具错误 LNK2026 XXX模块对于 SAFESEH 映像是不安全的
  14. SSH+ExtJS实战开发视频教程
  15. 中艺人脸识别考勤机使用方法_中控人脸识别考勤机说明书 人脸识别考勤机的使用方法...
  16. java 根号x_java如和开根号
  17. Topaz 全家桶最新中文版分享
  18. iOS 音乐播放器(二)
  19. 论找对客服妹子对修改邓白氏码的公司信息的重要性
  20. 【离散数学】单射、满射、双射、映射的合成与逆映射

热门文章

  1. The futex facility returned an unexpected error code
  2. 装饰器模式和适配器模式
  3. 如何快速提取图片中的文字信息、例如加密的pdf、不能复制的pdf文件
  4. 初学者指南: 使用NumPy数组进行图像处理
  5. ERROR: torch-1.4.0+cpu-cp38-cp38m-win_amd64.whl is not a supported wheel on this platform.
  6. 请给我发邮件,不要发微信
  7. 【微信小程序】数组push后,数组返回内容为数字
  8. Python安装包 阿里源
  9. 4种食物助你摆脱皮肤粗糙
  10. 微信小程序反编译wxss文件缺失_小程序反编译