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;的更多相关文章

  1. 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 原因 ...

  2. 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 ...

  3. Ubuntu下 ssh : connect to host localhost port 22:Connection refused

    Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...

  4. 运行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 ...

  5. ssh: connect to host localhost port 22: Connection refused

    1.hadoop安装好之后,执行ssh localhost无法执行, 提示“ssh: connect to host localhost port 22: Connection refused”. 2 ...

  6. 新手git: ssh: connect to host localhost port 22: Connection refused

    由于gitlab上要git pull或者git clone,可是每次都出现这个问题.之前偶尔出现这个问题.可是仅仅是偶尔.这是为什么呢?然后就開始搜索网上的解决方式了. 这个问题搜索网上非常多答案.可 ...

  7. ssh本机失败(ssh: connect to host localhost port 22: Connection refused)

    ssh本机失败(ssh: connect to host localhost port 22: Connection refused) 一. 问题描述 之前一直在服务上使用宝塔面板, 今天突发奇想, ...

  8. SMTP Error: Could not connect to SMTP host

    PHPMailer是一个非常棒的开源邮件类,使用也非常简单,但是对于虚拟主机来说,往往要受到各种限制.刚才我在虚拟主机上使用PHPMailer就遇到一个“SMTP Error: Could not c ...

  9. 【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邮箱 ...

随机推荐

  1. 解决VTune错误PMU resources currently being used by another profiling tool or process

    错误信息: When I ran Hardware Event-based Sampling Analysis 0, it showed the ERROR: Collection failed Co ...

  2. 3D数学读书笔记——矩阵进阶

    本系列文章由birdlove1987编写,转载请注明出处. 文章链接:http://blog.csdn.net/zhurui_idea/article/details/25242725 最终要学习矩阵 ...

  3. 基于Linux环境Tomcat-MySQL的server搭建

    在开发日趋激烈的今天.我们可不能再仅仅会编码了.这样搞不好.就成了一辈子的码奴!所以这里简单的分享一下server的搭建,因为Linux的安全性等一切因素让它成为了server平台的首选环境!今天跟大 ...

  4. iOS开发中权限再度梳理

    前言 上篇文章iOS开发中的这些权限,你搞懂了吗?介绍了一些常用权限的获取和请求方法,知道这些方法的使用基本上可以搞定大部分应用的权限访问的需求.但是,这些方法并不全面,不能涵盖住所有权限访问的方法. ...

  5. nyoj--68--三点顺序(数学)

    三点顺序 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 现在给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,现在让你判断A,B,C是顺时针给出的还是逆时针 ...

  6. Java-杂项:Java数组Array和集合List、Set、Map

    ylbtech-Java-杂项:Java数组Array和集合List.Set.Map 1.返回顶部 1. 之前一直分不清楚java中的array,list.同时对set,map,list的用法彻底迷糊 ...

  7. jqueryui slider

    <!doctype html><html lang="en"><head> <meta charset="utf-8" ...

  8. [jzoj 6080] [GDOI2019模拟2019.3.23] IOer 解题报告 (数学构造)

    题目链接: https://jzoj.net/senior/#main/show/6080 题目: 题意: 给定$n,m,u,v$ 设$t_i=ui+v$ 求$\sum_{k_1+k_2+...+k_ ...

  9. ROS-机器人建模与仿真概论

    前言:无论是因为高昂的设备费用还是为了减少实验次数,仿真都是十分必要的. ROS提供了很多优秀的仿真方式,下面来介绍一下: URDF:Unified Robot Description Format, ...

  10. Spring《四-一》解决自动装配的问题

    自动化装配使得研发减少了响应的指配工作,但是使得响应的检查难以完成. 解决方法: simple模式: <bean autowire="autodetect" dependen ...