javax.mail.MessagingException:无法连接到 SMTP 主机:mail.tranzlease.com,端口:465,响应:-1

发布于 2024-12-11 02:49:51 字数 2318 浏览 0 评论 0原文

可能的重复:
无法连接到 SMTP 主机:email-smtp.us-east-1.amazonaws.com,端口:465,响应:-1

我的应用程序在以下情况下显示此错误我尝试使用 JavaMail API 和我公司的邮件 ID 通过 Lotus Domino 服务器发送邮件:

javax.mail.MessagingException: 无法连接到 SMTP 主机:mail.tranzlease.com,端口:465,响应:-1

我可以通过我的 Gmail ID 发送邮件。

public void sendtoGroup(String sub,String msg) {
  try {
    String host = "mail.myweb.com";
    String from = "[email protected]";
    String pass = "12345";
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "false"); // added this line
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", from);
    props.put("mail.smtp.password", pass);
    props.put("mail.smtp.port", "465");
    props.put("mail.smtp.auth", "true");

    String[] to = {"[email protected]","[email protected]"}; 
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));

    InternetAddress[] toAddress = new InternetAddress[to.length];

    // To get the array of addresses
    for( int i=0; i < to.length; i++ ) { // changed from a while loop
        toAddress[i] = new InternetAddress(to[i]);
    }
    System.out.println(Message.RecipientType.TO);

    for( int i=0; i < toAddress.length; i++) { 
        message.addRecipient(Message.RecipientType.TO, toAddress[i]);
    }
    message.setSubject(sub);
    message.setText(msg);
    Transport transport = session.getTransport("smtp");
    transport.connect(host, from, pass);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  } catch(Exception e) {
    e.printStackTrace();
    }
  }
}

Possible Duplicate:
Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1

My application shows this error when I try to send mail through Lotus Domino server using JavaMail API with my company's mail ID:

javax.mail.MessagingException: Could not connect to SMTP host: mail.tranzlease.com, port: 465, response: -1

I am able to send the mail through my Gmail ID.

public void sendtoGroup(String sub,String msg) {
  try {
    String host = "mail.myweb.com";
    String from = "[email protected]";
    String pass = "12345";
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "false"); // added this line
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", from);
    props.put("mail.smtp.password", pass);
    props.put("mail.smtp.port", "465");
    props.put("mail.smtp.auth", "true");

    String[] to = {"[email protected]","[email protected]"}; 
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));

    InternetAddress[] toAddress = new InternetAddress[to.length];

    // To get the array of addresses
    for( int i=0; i < to.length; i++ ) { // changed from a while loop
        toAddress[i] = new InternetAddress(to[i]);
    }
    System.out.println(Message.RecipientType.TO);

    for( int i=0; i < toAddress.length; i++) { 
        message.addRecipient(Message.RecipientType.TO, toAddress[i]);
    }
    message.setSubject(sub);
    message.setText(msg);
    Transport transport = session.getTransport("smtp");
    transport.connect(host, from, pass);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  } catch(Exception e) {
    e.printStackTrace();
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心碎的声音 2024-12-18 02:49:51

这不是标准 SMTP 邮件端口(端口 25)。我认为端口 465 用于 SMTP+SSL。

确保您的管理员已在 Domino 服务器上启用“smtp over ssl”。

This is not the standard SMTP mail port (port 25). I think port 465 is for SMTP+SSL.

Make sure your admins have enabled "smtp over ssl" on the Domino server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文