我有一个Java程序,可以通过我们组织的Exchange服务器发送常规电子邮件。具有程序的服务器和交换服务器位于同一网络上。电子邮件被发送到几个单独的电子邮件地址和几个通讯组。所有收件人都在我们组织域的内部。在过去两年中,这种方法一直很好。
最近,我升级了项目的依赖项,以使用JavaMail的最新版本。进行此更改之后,我发现该电子邮件已成功到达各个电子邮件收件人,但是通讯组的成员没有收到该电子邮件。在将旧电子邮件与新电子邮件进行比较之后,只有一个区别。此标头:
X-Ms-Exchange-Organization-Authas: Internal
已更改为:
X-Ms-Exchange-Organization-Authas: Anonymous
我不完全理解此标头的含义,但是我认为这可能是通讯组不接收电子邮件的原因,因为它们被设置为仅接收内部电子邮件。注意到此问题后,我将更改恢复为JavaMail库版本,但问题仍然存在。 FWIW,JavaMail调试输出将通讯组地址验证为“确定”。
那么,如何使Exchange服务器识别这是内部电子邮件?
下面是发送电子邮件的代码,其中删除了敏感信息。同样,这段代码在尝试更新库之前已经工作了几年。我还要提到的是,通讯组本身看起来还不错,他们像平常一样收到了其他电子邮件。
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", "XXXXXXXX");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", "587");
props.put("mail.smtp.connectiontimeout", "30000");
props.put("mail.smtp.timeout", "30000");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("XXXXXX", "XXXXXX");
}
});
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress("XXXXXXXXX"));
// Set the to address
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXXXX"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("XXXXXXXXXXXXX"));
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
String formDate = formatter.format(date);
// Set the subject
message.setSubject("Incident Report Dispositions: " + formDate);
// Set the content
message.setContent(body, "text/html; charset=utf-8");
// Send message
Transport.send(message);
编辑:我还注意到“匿名”电子邮件缺少此标头:
X-Ms-Exchange-Organization-Authmechanism: 00