简体   繁体   English

Java邮件创建DSN(交付状态通知)

[英]Java mail create DSN (Delivered Status Notification)

I want to create DSN (delivered status notification) and send back to sender. 我想创建DSN(交付状态通知)并发送回发件人。 I use MimeMulitPartReport and add 3 part of body. 我使用MimeMulitPartReport并添加正文的3部分。 However, it does not work. 但是,它不起作用。 In the recipient side, it does not show a human readable message and DSN information. 在接收方,它不会显示人类可读的消息和DSN信息。 I can't figure out, what's wrong in my code. 我不知道,我的代码有什么问题。

Thank you 谢谢

I use JavaMail 1.4.5 with DSN extension http://www.oracle.com/technetwork/java/javamail/index-141777.html : 我使用具有DSN扩展名http://www.oracle.com/technetwork/java/javamail/index-141777.html的 JavaMail 1.4.5:

private MimeMessage dsnEmail() throws MessagingException {
    MimeMessage msg = new MimeMessage(mailSession);
    MultipartReport multipart = new MultipartReport(
            HUMAN_READABLE_MSG,
            new DeliveryStatus(),
            originalEmail
    );
    msg.setContent(multipart);
    msg.setSubject("Delivery Status Notification (failure)");
    msg.setRecipient(Message.RecipientType.TO, originalEmail.getSender());
    return msg;
}

with this maven import : 与此Maven导入:

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>dsn</artifactId>
    <version>1.4.5</version>
</dependency>

I hope it helps 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM