简体   繁体   English

com.sun.mail.util.MailConnectException:无法连接到主机,端口:smtp.gmail.com,587; 超时-1

[英]com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1

I had implemented the ability to send email to Java. 我已经实现了将电子邮件发送到Java的功能。 However, from the moment I get the following error: 但是,从那一刻起,我得到以下错误:

DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user=USERNAME, password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL true
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
  nested exception is:
    java.net.ConnectException: Connection refused: connect

I think my code is not wrong. 我认为我的代码没有错。 Because my code works well on my two colleagues' PC. 因为我的代码在我的两个同事的PC上运行良好。 (telnet smtp.gmail.com 587) command works well. (telnet smtp.gmail.com 587)命令效果很好。

Help me please. 请帮帮我。 I could not do anything for a few days because of this. 因此,我几天都不能做任何事情。

I am a beginner and I would appreciate it if you could let me know. 我是一个初学者,如果您能告诉我,我将不胜感激。

According to this : 根据这个 :

"Because my code works well on my two colleagues' PC. (telnet smtp.gmail.com 587) command works well" “因为我的代码在我的两个同事的PC上运行良好。(telnet smtp.gmail.com 587)命令运行良好”

i assume that you already authorize access through less secure app in the gmail account you're using, and the problem is related to your own computer. 我假设您已经通过使用的gmail帐户中的安全性较低的应用授权访问,而问题与您自己的计算机有关。

Did you check your firewall or antivirus rules ? 您是否检查了防火墙或防病毒规则?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.sun.mail.util.MailConnectException:无法连接到主机,端口:本地主机,25; 超时 -1; - com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; 邮件服务器连接失败; 嵌套异常是 com.sun.mail.util.MailConnectException:无法连接到主机,端口:localhost,25; 超时-1; - Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; JavaMail API不适用于我,但出现了com.sun.mail.util.MailConnectException异常:无法连接到主机,端口 - JavaMail API doesn't work for me with an exception com.sun.mail.util.MailConnectException: Couldn't connect to host, port javax.mail.MessagingException:无法连接到 SMTP 主机:smtp.gmail.com,端口:587 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587 javax.mail.MessagingException:无法连接到SMTP主机:smtp.gmail.com,端口:587; java.net.NoRouteToHostException:主机没有路由 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; java.net.NoRouteToHostException: No route to host javax.mail.MessagingException:无法连接到SMTP主机:smtp.gmail.com,端口:587无法管理解决此问题 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587 Can not manage to solve this problem 无法连接到 SMTP 主机:smtp.gmail.com,端口:Windows Server 2016 上的 587 - Could not connect to SMTP host: smtp.gmail.com, port: 587 on windows server 2016 smtp.gmail.com,端口:587 失败 - smtp.gmail.com, port: 587 fails 无法连接到SMTP主机:smtp.gmail.com,port:587; 嵌套异常是:java.net.ConnectException:连接超时:连接 - Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out: connect 无法连接到SMTP主机:smtp.gmail.com,端口:465 - could not connect to smtp host:smtp.gmail.com, port:465
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM