阿里云邮件推送报错Could not connect to SMTP host: smtpdm.aliyun.com, port: 465解决方法

查阅了很多资料与百度谷歌了很久,网上很多配置

props.setProperty("mail.transport.protocol", "SMTP"); 说SMTP得大写 测试无效
props.setProperty("mail.smtp.socketFactory.fallback", "false");  也是无效
props.put("mail.smtp.ssl.enable", true); 也是无效

因为本地上运行是可以发送邮件的,线上环境却不行

本地环境为1.8 线上环境为11 所以在想是是不是环境导致的

有了想法就行动起来

查阅了很多资料说是java.security中配置文件不要SSL3,TLSv1, TLSv1.1配置

由于部署环境是在docker中,所以直接在代码中加入一行代码即可解决

props.put("mail.smtp.ssl.protocols", "TLSv1.2");

再测试发送,发送成功!完美

最后上一下代码

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
As an AI language model, I am not able to troubleshoot network issues or provide technical support. However, this error message usually means that the host "mirrors.aliyun.com" cannot be reached or resolved by the computer or device attempting to access it. Some possible causes for this error include: - DNS issues: The computer or device may not be able to resolve the domain name to an IP address. This could be due to a misconfigured DNS server or a problem with the network connection. - Firewall or proxy restrictions: The computer or device may be blocked from accessing the specified host by a firewall or proxy server. This could be due to security policies or network restrictions. - Server or network outage: The host may be temporarily unavailable due to maintenance or other issues. To troubleshoot this issue, you may try the following steps: - Check your network connection: Make sure that your computer or device is connected to the internet and that there are no connectivity issues. - Check your DNS settings: Ensure that your DNS settings are correct and that your computer or device can resolve domain names. - Check your firewall or proxy settings: If you are behind a firewall or proxy server, check that it is not blocking access to the specified host. - Try accessing the host from a different device or network: If possible, try accessing the host from a different device or network to see if the issue persists. If none of these steps resolves the issue, you may need to contact your network administrator or technical support for further assistance.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值