阿里云Could not connect to SITP host: smtp.163.com,port: 25;

简介: 阿里云Could not connect to SITP host: smtp.163.com,port: 25;

一、问题描述

系统发送邮件,采用的是网易邮箱,本地环境没问题,部署到阿里云,控制台报504查看日志,系统连接网易邮箱服务器超时;

二、原因分析

原因:阿里云服务器封禁了25端口,即使安全组放开,无济于事;

三、解决方法

解决方法:开启SSL使用465端口进行发送(放开阿里云安全组465端口);

实现:

避免采坑,使用hutool提供的MailUtil工具类进行邮件发送;

         <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.7.22</version>
        </dependency>
 
        <!-- 邮箱-->
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

根据需要,可以再封装一层,编写自己的MyMailUtil,减少参数设置;

MailAccount account = new MailAccount();
//邮箱服务器SMTP地址
account.setHost("smtp.yeah.net");
//端口
account.setPort("465");
 
//是否需要用户名密码验证
account.setAuth(true);
 
//发送人
account.setFrom("hutool@yeah.net");
 
//发送用户
account.setUser("hutool");
 
//发送用户的密码或者授权码
account.setPass("q1w2e3");
 
//使用SSL安全连接
account.setSslEnable(true);
 
 
//发送配置、收件人、主题、内容、是否html
 
MailUtil.send(account,"hutool@foxmail.com", "测试", "邮件来自Hutool测试", false);


相关文章
|
安全 Java Linux
Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
839 0
|
9月前
|
Ruby
|
9月前
|
数据安全/隐私保护 Ruby
|
9月前
|
数据安全/隐私保护 Ruby
|
4月前
|
Python
python使用smtp发送邮件
python使用smtp发送邮件
62 0
|
6月前
|
数据安全/隐私保护
【Azure Logic App】在Azure Logic App中使用SMTP发送邮件示例
【Azure Logic App】在Azure Logic App中使用SMTP发送邮件示例
|
8月前
|
网络安全 数据安全/隐私保护 Python
Python SMTP发送邮件
Python SMTP发送邮件
|
7月前
|
JavaScript API PHP
不用SMTP实现联系表单提交后发送邮件到指定邮箱
构建网站时,联系表单可通过邮件API(如SendGrid、Mailgun、Amazon SES)或第三方自动化服务(Zapier、Integromat)无需SMTP发送邮件。这些服务提供API接口和自动化工作流程,简化邮件发送。例如,使用SendGrid API在Python中发送邮件涉及注册、获取API密钥并编写发送邮件的代码。同样,Zapier可作为表单提交的触发器,自动发送邮件。此外,后端脚本(如PHPMailer)也能实现这一功能,但需编写处理SMTP的代码。选择适合的方法能优化邮件发送流程。
|
网络安全 数据安全/隐私保护
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
372 0