[英]Java add header in MimeMessage msg
Problem that i'm solving is that when i send mail if the recipient (to mails, cc/bcc) not exist, i don't want sender to get Delivery Status Notification (Failure) mail. 我正在解决的问题是,当我发送邮件时,如果收件人(邮件,cc / bcc)不存在,我不希望发件人获得传递状态通知(失败)邮件。
The solution that i'm implementing is adding new header in mail Prevent-NonDelivery-Report 我正在实施的解决方案是在邮件Prevent-NonDelivery-Report中添加新标头
I want to add new header in MimeMessage msg in java 我想在java中的MimeMessage msg中添加新标头
// this is part of the code that defined the mime message
Session session = Session.getDefaultInstance(props, null);
// we create message
Message msg = new MimeMessage(session);
// this code is not working for me
msg.addHeader("Prevent-NonDelivery-Report", "");
I found the solution i add props.setProperty("mail.smtp.dsn.notify", "NEVER") to the property of the session and that fix my problem 我发现解决方案我将props.setProperty(“mail.smtp.dsn.notify”,“从不”)添加到会话的属性,并解决了我的问题
On behalf of the OP: 代表OP:
I found the solution. 我找到了解决方案。 I add: 我加:
props.setProperty("mail.smtp.dsn.notify", "NEVER")
to the property of the session and that fix my problem. 到会话的属性,并解决我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.