关于阿里云服务器上使用javamail失败的解决方案
来源:互联网 发布:萧山问政网络平台 编辑:程序博客网 时间:2024/05/29 08:25
今天出现一个奇怪的问题, 本地的邮件能正常发送. 代码上传到阿里云服务器上就是不能成功.
在阿里云社区上看到这么一篇帖子, https://yq.aliyun.com/ask/47591
后台发现写的代码没有使用ssl的连接方式.
Properties props = new Properties(); // 开启debug调试 // props.setProperty("mail.debug", "true"); // 发送服务器需要身份验证 props.setProperty("mail.smtp.auth", "true"); // 设置邮件服务器主机名 props.setProperty("mail.host", "smtp.9meth.com"); // 发送邮件协议名称 //props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.setProperty("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.smtp.port", "465"); props.setProperty("mail.smtp.socketFactory.port", "465"); // 设置环境信息 // Session session = Session.getInstance(props); Session session = Session.getDefaultInstance(props, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("mail", "password"); } });// 创建邮件对象 Message msg = new MimeMessage(session); try { msg.setSubject(title); // 设置邮件内容 msg.setText(content); // 设置发件人 msg.setFrom(new InternetAddress("发的邮件")); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(收的邮件, false)); Transport.send(msg); } catch (MessagingException e) { e.printStackTrace(); }
阅读全文
0 0
- 关于阿里云服务器上使用javamail失败的解决方案
- 关于服务器上发送邮件程序发送失败的解决方案
- 关于阿里云服务器使用
- 关于阿里云服务器上连接的问题
- 使用Navicat连接阿里云服务器上的MySQL数据库
- 阿里云服务器的域名解析解决方案
- 阿里云服务器的使用
- 关于SecureCRT连接阿里云服务器提示需要public key的解决方案
- 访问阿里云服务器上的neo4j
- 使用javamail、阿里云邮箱发送邮件
- 关于如何连接阿里云服务器上的MySQL数据库的解答
- 在红帽子下配置javamail服务器,使用外面的邮箱地址发送邮件失败
- 关于本地mysql客户端如何连接阿里云服务器上的MySQL数据库
- 关于javamail的使用心得
- 使用Navicat远程阿里云服务器上MySQL
- 阿里云的ECS服务器的使用
- 使用阿里云服务器
- 使用squid在阿里云服务器上搭建自己的代理服务器
- 梦网云通讯获取API上行接口get_mo说明POST实例
- UE4-XML与JSon的简单读写实现
- 《Android源码设计模式解析与实战》读书笔记(二十三)——外观模式
- echart 重叠 以及添加更多的图例
- 机器学习--监督学习之梯度下降法
- 关于阿里云服务器上使用javamail失败的解决方案
- android 如何保护我们的app(二)(干货)
- 常用的第三方框架,学习网站,常用知识
- 数据库为什么要分库分表
- 安装PyTables出现 ImportError: Could not load [hdf5dll.dll,hdf5.dll] 错误解决
- SpringMVC框架学习(注解开发)
- app开发利器 delphi xe
- python 程序打包成exe py2exe
- webpack如何正确分离css