Could not connect to SMTP host: smtp.163.com, port: 465, response: -1
1.用以下代码,邮件发送测试失败
JavaMailSenderImpl tempMailSender = new JavaMailSenderImpl();
tempMailSender.setHost(mqCloudConfigHelper.getMailHost());
tempMailSender.setPort(mqCloudConfigHelper.getMailPort());
tempMailSender.setProtocol(mqCloudConfigHelper.getMailProtocol());
tempMailSender.setUsername(mqCloudConfigHelper.getMailUsername());
tempMailSender.setPassword(mqCloudConfigHelper.getMailPassword());
Properties props = new Properties();
props.put("mail." + mqCloudConfigHelper.getMailProtocol() + ".auth", true);
props.put("mail." + mqCloudConfigHelper.getMailProtocol() + ".connectiontimeout",mqCloudConfigHelper.getMailTimeout());
props.put("mail." + mqCloudConfigHelper.getMailProtocol() + ".timeout",mqCloudConfigHelper.getMailTimeout());
tempMailSender.setJavaMailProperties(props);
tempMailSender.testConnection();
javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2106)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712)
at javax.mail.Service.connect(Service.java:366)
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:501)
at org.springframework.mail.javamail.JavaMailSenderImpl.testConnection(JavaMailSenderImpl.java:382)
at com.sohu.tv.mq.cloud.service.impl.DefaultAlertMessageSender.init(DefaultAlertMessageSender.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
2.解决办法
方法一:加多以下这句
props.put("mail.smtp.ssl.enable", true);
方法二:修改发送端口
将465端口改为25端口
Could not connect to SMTP host: smtp.163.com, port: 465, response: -1相关推荐
- Azkaban重新编译,解决:Could not connect to SMTP host: smtp.163.com, port: 465【2022年01月10日】
Azkaban配置文件修改465端口一直报错,如下: javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.c ...
- Java发送QQ邮件问题Could not connect to SMTP host: smtp.qq.com, port: 465(内附完整代码)
邮件发送失败,本地测试可以,部署到服务器就不行. 之前就碰到这个问题,解决办法就是把port端口改成587,然后注释这一段 MailSSLSocketFactory sf = new MailSSLS ...
- JAVA服务器端发送邮件问题:Could not connect to SMTP host: smtp.qq.com, port: 465
前言 在开发过程中,发送邮件经过测试是没有问题,然后部署到服务器中(腾讯云服务器),发送邮件一直报Could not connect to SMTP host: smtp.qq.com, port: ...
- Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
引言 在前面博客中写了关于java发送邮件的博客,但是当项目部署到linux 服务器上的时候,发送遇到了错误,如下: Could not connect to SMTP host: smtp.***. ...
- 使用mail发送邮件 报错找不到服务器Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
使用mail发送邮件 报错找不到服务器 /*** 背景* 在使用javamail进行邮件发送的时候,报错:* Could not connect to SMTP host: smtp.***.com, ...
- Could not connect to SMTP host: smtp.126.com, port: 25
使用javamail发送邮件的时候,我使用的是网易126邮箱 126邮箱的SMTP服务器地址:smtp.126.com(端口:25) 注:这个链接可以查到各个邮箱的SMTP服务器地址 常用邮箱SMTP ...
- 解决问题:javax.mail.MessagingException: Could not connect to SMTP host: smtp.exmail.qq.com, port: 25;
最近项目中需要用到发送邮件这一功能,总是遇到这样的一个报错: javax.mail.MessagingException: Could not connect to SMTP host: smtp.e ...
- 线上发送邮件问题记录(Could not connect to SMTP host:smtp.exmail.qq.com,port:465)
事件回顾到某天下班,然后听到手机消息,来自企业微信,是财务小姐姐向我发来了问候,问我为什么邮件突然就发不出去了. 我也愣住了,这个功能是去年做的了,一直没有什么问题,甚至另一个系统也是copy我的代码 ...
- 写定时任务发送邮件报错(Could not connect to SMTP host:smtp.exmail.qq.com,port:465)
需求阐述 在写完定时任务发送邮件之后,调试的时候发现报错:Could not connect to SMTP host:smtp.exmail.qq.com,port:465.一开始我以为是在for循 ...
最新文章
- 求合体电脑版_SCP CB 电脑移植版测评
- django+jquery ajax post csrf 配置
- android ip 黑白名单,GaussDB T 单机 IP黑白名单配置
- 文件系统管理 之 文件和目录访问权限设置
- Python多线程--UDP聊天器
- 845B - Luba And The Ticket
- linux nsf 扫描,linux 使用NSF 映射远程磁盘目录的实现
- WEB程序设计 第7版.pdf
- 基于YOLO3的人数统计程序
- 在线搭建自己的网课答案公众号题库系统
- 网易云易盾正式成为“中国短视频与直播联盟”常务理事
- GDK事件与GTK signal的前世今生
- 你的爬虫是否徘徊在违法的边缘?
- 华为WATCH 3手表怎么收能量,速领手表一键收能量
- Eclipse插件2
- 轮盘赌算法原理(ACO算法概率选择方法)
- 对话本体创始人李俊——有关IEO、DApp、区块链游戏的一些冷思考
- 可重入锁详解(什么是可重入)
- 机器学习入门 01 —— 机器学习概述
- 转.CNNIC,我不信任你! ——从“受信任的根证书”里赶走CNNIC
热门文章
- NetWORK ShortCuts 创建
- 学习初步练习基于c语言的socket编程
- 宽带计费认证系统的PPPoE认证技术
- Caffe2 - (十六) 创建 LMDB 数据库
- Contiki开发要点
- python中字符串转数组、数组转字符串
- PPP协议(PPP协议链路建立过程、PAP、CHAP、华为虚拟网络设备配置)
- java实现微博网站设计_基于jsp的微博网站-JavaEE实现微博网站 - java项目源码
- matlab求x对应y值,matlab已知f(x,y)=0,已知一组x如何求对应的y值? - 计算模拟 - 小木虫 - 学术 科研 互动社区...
- 新绝代双骄3终极全攻略3