Could not connect to SMTP host: smtp.163.com, port: 25;阿里云 ECS
来源:互联网 发布:蹭网软件下载 编辑:程序博客网 时间:2024/05/18 05:34
ECS基于安全考虑,目前已禁用25端口。
如果您的发送程序部署在阿里云ECS上,建议您不勾选SSL时,使用80端口,勾选SSL时,使用465端口。
测试端口 telnet smtp.163.com 25
测试网络 ping smtp.163.com
import javax.mail.*;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeMessage;import java.util.Properties;public class SimpleAliDMSendMail { private static final String ALIDM_SMTP_HOST = "smtpdm.aliyun.com"; private static final int ALIDM_SMTP_PORT = 25; public static void main(String[] args) throws MessagingException { // 配置发送邮件的环境属性 final Properties props = new Properties(); // 表示SMTP发送邮件,需要进行身份验证 props.put("mail.smtp.auth", "true"); props.put("mail.smtp.host", ALIDM_SMTP_HOST); props.put("mail.smtp.port", ALIDM_SMTP_PORT); // 如果使用ssl,则去掉使用25端口的配置,进行如下配置, // props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); // props.put("mail.smtp.socketFactory.port", "465"); // props.put("mail.smtp.port", "465"); // 发件人的账号 props.put("mail.user", "***"); // 访问SMTP服务时需要提供的密码 props.put("mail.password", "***"); // 构建授权信息,用于进行SMTP进行身份验证 Authenticator authenticator = new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { // 用户名、密码 String userName = props.getProperty("mail.user"); String password = props.getProperty("mail.password"); return new PasswordAuthentication(userName, password); } }; // 使用环境属性和授权信息,创建邮件会话 Session mailSession = Session.getInstance(props, authenticator); // 创建邮件消息 MimeMessage message = new MimeMessage(mailSession); // 设置发件人 InternetAddress form = new InternetAddress( props.getProperty("mail.user")); message.setFrom(form); // 设置收件人 InternetAddress to = new InternetAddress("***"); message.setRecipient(MimeMessage.RecipientType.TO, to); // 设置邮件标题 message.setSubject("测试邮件"); // 设置邮件的内容体 message.setContent("测试的HTML邮件", "text/html;charset=UTF-8"); // 发送邮件 Transport.send(message); }}
阅读全文
0 0
- Could not connect to SMTP host: smtp.163.com, port: 25;阿里云 ECS
- Could not connect to SMTP host: smtp.163.com, port: 25
- Could not connect to SMTP host: smtp.qq.com, port: 25;
- 解决问题: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.qq.com, port: 25;
- Could not connect to SMTP host: pop.163.com, port: 25 解决方案
- Could not connect to SMTP host: localhost, port: 25;
- javax.mail.MessagingException: Could not connect to SMTP host: smtp.xx.com, port: 465;
- 关于应用javamail的心得::Could not connect to SMTP host: smtp.sina.cn, port: 25
- javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
- 关于使用Java Mail进行邮件发送,抛出Could not connect to SMTP host: xx@xxx.com, port: 25的异常可能
- 关于使用Java Mail进行邮件发送,抛出Could not connect to SMTP host: xx@xxx.com, port: 25的异常可能
- 发送自动邮件时Could not connect to SMTP host: 10.1.1.195, port: 25;报错的解决方法
- 解决2个smtp的问题: SMTP Error: Could not connect to SMTP host.
- javamail javax.mail.MessagingException: Could not connect to SMTP host:
- javax.mail.MessagingException: Could not connect to SMTP host
- wordpress之SMTP发送邮件出现Could not connect to SMTP host解决办法
- PHPMailer错误SMTP Error: Could not connect to SMTP host的解决办法
- SVM中的核函数
- java填充替换数组元素
- poj2774
- 利用PHPExcel导出Excel并设置Excel格式
- CodeForces #157(258A|258B|258C|258D|258E)|数位DP|搜索|线段树
- Could not connect to SMTP host: smtp.163.com, port: 25;阿里云 ECS
- Master启动的源码详解
- TCP网络编程中connect()、listen()和accept()三者之间的关系
- 递归
- Directx11教程四十三之glow(边缘发光)
- Word文档插图片问题
- 写接口请求类型为get或post的时,参数定义的几种方式,如何用注解(原创)--雷锋
- Linux C 进程间的IPC通信 之 共享内存(一)
- Ubuntu16.04搜狗拼音输入法候选栏无法显示中文(英文乱码)