[英]How to configure JavaMail for Microsoft Exchange?
I am trying to connect to a Microsoft Exchange (2010) mail account using JavaMail 1.5.1. 我正在尝试使用JavaMail 1.5.1连接到Microsoft Exchange(2010)邮件帐户。 When I try to connect, I get the following exception.
当我尝试连接时,出现以下异常。
Exception in thread "main" com.sun.mail.util.MailConnectException:
Couldn't connect to host, port: domain server, 25; timeout -1;
nested exception is:
java.net.SocketException: Permission denied: connect
Here is the code I am using. 这是我正在使用的代码。
public class SendMail
{
public void mail () throws MessagingException
{
Properties props = System.getProperties();
String protocol = "smtp";
// Setup mail server
props.put("mail." + protocol + ".host", "domain server");
props.put("mail." + protocol + ".auth", "true");
props.put("mail." + protocol + ".port", "25");
Session session = Session.getInstance(props);
Transport t = session.getTransport(protocol);
try{
t.connect("domain\\user name", "password");
}
finally{
t.close();
}
}
}
What I am doing wrong? 我做错了什么?
Replace domain server with the actual server name in exception and code. 用 异常和代码中的实际服务器名称 替换 域服务器 。
默认情况下 ,Exchange服务器上未启动SMTP,因此我建议您仅使用Exchange本身
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.