相关疑难解决方法(0)

发送邮件错误,javax.mail.MessagingException:无法连接到SMTP主机:localhost,port:25;

这是我的代码

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;


public class MailSendClass {
    public static void main (String [] args){

      // Recipient's email ID needs to be mentioned.
      String to = "abc82@gmail.com";

      // Sender's email ID needs to be mentioned
      String from = "xyz@gmail.com";

      // Assuming you are sending email from localhost
      String host = "localhost";

      // Get system properties
      Properties properties = System.getProperties();

      // Setup mail server
      properties.setProperty("mail.smtp.host", host);

      // Get the default …
Run Code Online (Sandbox Code Playgroud)

java netbeans sendmail jakarta-mail connectionexception

8
推荐指数
1
解决办法
7万
查看次数

为什么我只在某些Windows 7系统上需要java.net.preferIPv4Stack = true?

我在Windows 7(64位)计算机上使用Java已经有一段时间了,并且从未遇到过无法创建网络连接的问题.现在在我正在工作的公司的系统上我需要设置"-Djava.net.preferIPv4Stack = true"或者似乎java进程无法创建单个连接.

缺点是,如果我没有设置"_JAVA_OPTIONS",我将不得不配置大量服务来使用此设置.但是,如果我使用它,Java将这个愚蠢的"拾起:_JAVA_OPTIONS ......"输出到stderr(不知道哪个人做出了那个愚蠢的决定).然而,这使得我的GWT编译在IntelliJ中失败.

我想知道的......这是我第一次遇到这些问题,我猜他们必须以某种方式与操作系统的设置有关.可能导致这些问题的原因(正如我所提到的......我有大约4个其他具有Windows 7和64位java vms的系统没有这些问题).

克里斯

java networking windows-7

5
推荐指数
1
解决办法
3万
查看次数