javax.mail.MessagingException:无法连接到 SMTP 主机:mail.tranzlease.com,端口:465,响应:-1
可能的重复:
无法连接到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是标准 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.