我的应用程序将电子邮件发送到联系人列表,我想捕获OOO(外出)电子邮件,以自动检测谁在休假,并(基于消息)(希望)发现他/她何时回来。我正在尝试使用Sendgrid和Mailgun的入站解析功能来做到这一点。
两者具有相同的行为:当我手动发送电子邮件时,它们可以正常工作,但是由于某些原因,它们会忽略自动响应OOO消息。有人知道发生了什么吗?
在这两种情况下,我都使用Java库。以下是代码片段:
Mailgun:
@Test
public void shouldSendEmailUsingMailgun() throws Exception {
Configuration configuration = new Configuration()
.domain("<my_domain>")
.apiKey("<my_api_key>")
.from("<from>", "[email protected]");
Mail.using(configuration)
.to("[email protected]")
.subject("Mailgun testing OOO with reply-to")
.text("Hello, from Mailgun")
.replyTo("[email protected]")
.build()
.send();
}
森格
Email from = new Email("[email protected]");
String subject = "This is a test announcement from ooo detection";
Email to = new Email("<recipient>");
Content content = new Content("text/plain", "Hello, Email!");
Mail mail = new Mail(from, subject, to, content);
Email replyTo = new Email("[email protected]");
mail.setReplyTo(replyTo);
SendGrid sg = new SendGrid("<api_key>");
Request request = new Request();
try {
request.method = Method.POST;
request.endpoint = "mail/send";
request.body = mail.build();
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
谢谢!
最佳答案
您可能需要查看功能更全的入站解析器,例如Mailparser.io
我对Mailgun的实现不熟悉,但是SendGrid的Parse实现非常基础。假设它配置正确,它应该将OOO响应发送到您的端点,但是它没有逻辑来解析主体,因此您必须自己这样做。
关于java - 如何使用入站解析捕获OOO(不在办公室)电子邮件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41511175/