可能重复:
Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1
当我尝试使用JavaMail API通过Lotus Domino服务器使用我公司的邮件ID发送邮件时,我的应用程序显示此错误:
javax.mail.MessagingException: Could not connect to SMTP host: mail.tranzlease.com, port: 465, response: -
1
我可以通过我的Gmail ID发送邮件。
public void sendtoGroup(String sub,String msg) {
try {
String host = "mail.myweb.com";
String from = "vinod.patil@myweb.com";
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 = {"vinod.patil@myweb.com","vinodpatil76@rediffmail.com"};
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();
}
}
}
答案 0 :(得分:0)
这不是标准的SMTP邮件端口(端口25)。我认为端口465适用于SMTP + SSL。
确保您的管理员在Domino服务器上启用了“smtp over ssl”。