Could not connect to SMTP host: localhost, port: 25;
1、错误描写叙述
DEBUG: setDebug: JavaMail version 1.3.3
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "localhost", port 25, isSSL false
Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1227)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:322)
at javax.mail.Service.connect(Service.java:236)
at javax.mail.Service.connect(Service.java:137)
at com.you.mail.model.SendMessage.sendMessage(SendMessage.java:70)
at com.you.mail.model.SendMessage.main(SendMessage.java:89)
2、错误原因
从报错可知,无法连接SMTP服务主机
3、解决的方法
配置正确的SMTP服务主机。保证服务连接上
String server = "smtp.163.com";
String username = "";
String password = ""; Transport transport = session.getTransport();
transport.connect(server, username, password);
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();
Could not connect to SMTP host: localhost, port: 25;的更多相关文章
- Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
背景 在使用javamail进行邮件发送的时候,报错: Could not connect to SMTP host: smtp.***.com, port: 465, response: -1 原因 ...
- mac connect to host localhost port 22: Connection refused
在Mac OS X 10.10.5学习hadoop的过程中,输入命令ssh localhost得到 ssh: connect to host localhost port : Connection r ...
- Ubuntu下 ssh : connect to host localhost port 22:Connection refused
Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...
- 运行Hadoop start-all.sh遇到的错误ssh: connect to host localhost port 22: Connection refused
ssh: connect to host localhost port 22: Connection refused 我的情况是ssh server没装,查看方法: ps -e |grep ssh 1 ...
- ssh: connect to host localhost port 22: Connection refused
1.hadoop安装好之后,执行ssh localhost无法执行, 提示“ssh: connect to host localhost port 22: Connection refused”. 2 ...
- 新手git: ssh: connect to host localhost port 22: Connection refused
由于gitlab上要git pull或者git clone,可是每次都出现这个问题.之前偶尔出现这个问题.可是仅仅是偶尔.这是为什么呢?然后就開始搜索网上的解决方式了. 这个问题搜索网上非常多答案.可 ...
- ssh本机失败(ssh: connect to host localhost port 22: Connection refused)
ssh本机失败(ssh: connect to host localhost port 22: Connection refused) 一. 问题描述 之前一直在服务上使用宝塔面板, 今天突发奇想, ...
- SMTP Error: Could not connect to SMTP host
PHPMailer是一个非常棒的开源邮件类,使用也非常简单,但是对于虚拟主机来说,往往要受到各种限制.刚才我在虚拟主机上使用PHPMailer就遇到一个“SMTP Error: Could not c ...
- 【Linux】【Jenkins】邮件发送失败的问题javax.mail.MessagingException: Could not connect to SMTP host:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.126.com,port:25 解决方案: 之前用的是126邮箱 ...
随机推荐
- iOS相册实现与AssetsLibrary框架使用
概述 在iOS中如果想要获取手机相册里面的图片或者视频的话就要用到系统自带的AssetsLibrary框架,AssetsLibrary.framework中包含以下文件 #import <Ass ...
- 具体验证身份证号码规则和姓名(汉字)的java代码
一.验证汉字的正則表達式 /** 是否是汉字的正则 */ private String regexIsHanZi = "[\\u4e00-\\u9fa5]+"; * @pa ...
- JavaSE 最easy出错的几个简单的问题
案例1. package cn.itcast.oop; public class ThisDemo { public static void main(String[] args) { Student ...
- c# DataTable to Object Mapping
public static class DataTableExtensions { public static IList<T> ToList<T>(this DataTabl ...
- lightoj--1354-- IP Checking(水题)
IP Checking Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Sta ...
- 【HNOI 2004】宠物收养所
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1208 [算法] 建两棵平衡树维护领养者和宠物的特点值,这两棵平衡树支持 插入删除,查 ...
- ubuntu下无法将iNode绑定到侧边栏的解决办法
title: ubuntu下无法将iNode绑定到侧边栏的解决办法 toc: false date: 2018-09-01 17:43:52 categories: methods tags: ubu ...
- 压力测试工具 Tinyget
Tinyget 压力测试工具使用方法为:命令行切换到工具所在路径下,然后输入压力命令.如:tinyget -srv:localhost -uri:/FeaturedProdu1cts.aspx -th ...
- 使用Latex写book类型文本的体会
晚上参考中科院上海交大清华北大等学校的模板,终于重新把博一时候没解决的问题解决了.中科院吴老师的CTeX论坛因为维护压力比较大不得不关了,查不到之前的Latex解决答案.经过一下午和一晚上的摸索,忽然 ...
- CSS3中的2D和3D转换知识介绍
一 2D转换 转换是CSS3中具有颠覆性的特征之一,可以实现元素的位移.旋转.变形.缩放,甚至支持矩阵方式,配合即将学习的过渡和动画知识,可以取代大量之前只能靠Flash才可以实现的效果. 1.移动 ...