• <legend id='LbLMk'><style id='LbLMk'><dir id='LbLMk'><q id='LbLMk'></q></dir></style></legend><tfoot id='LbLMk'></tfoot>
  • <small id='LbLMk'></small><noframes id='LbLMk'>

          <bdo id='LbLMk'></bdo><ul id='LbLMk'></ul>
        <i id='LbLMk'><tr id='LbLMk'><dt id='LbLMk'><q id='LbLMk'><span id='LbLMk'><b id='LbLMk'><form id='LbLMk'><ins id='LbLMk'></ins><ul id='LbLMk'></ul><sub id='LbLMk'></sub></form><legend id='LbLMk'></legend><bdo id='LbLMk'><pre id='LbLMk'><center id='LbLMk'></center></pre></bdo></b><th id='LbLMk'></th></span></q></dt></tr></i><div id='LbLMk'><tfoot id='LbLMk'></tfoot><dl id='LbLMk'><fieldset id='LbLMk'></fieldset></dl></div>

        如何使用 javax.mail 设置或更改 SMTP 消息 ID?

        How do I set or change the SMTP Message-ID with javax.mail?(如何使用 javax.mail 设置或更改 SMTP 消息 ID?)
              • <bdo id='b72qM'></bdo><ul id='b72qM'></ul>
                <legend id='b72qM'><style id='b72qM'><dir id='b72qM'><q id='b72qM'></q></dir></style></legend>

                <tfoot id='b72qM'></tfoot>

                    <tbody id='b72qM'></tbody>
                1. <small id='b72qM'></small><noframes id='b72qM'>

                  <i id='b72qM'><tr id='b72qM'><dt id='b72qM'><q id='b72qM'><span id='b72qM'><b id='b72qM'><form id='b72qM'><ins id='b72qM'></ins><ul id='b72qM'></ul><sub id='b72qM'></sub></form><legend id='b72qM'></legend><bdo id='b72qM'><pre id='b72qM'><center id='b72qM'></center></pre></bdo></b><th id='b72qM'></th></span></q></dt></tr></i><div id='b72qM'><tfoot id='b72qM'></tfoot><dl id='b72qM'><fieldset id='b72qM'></fieldset></dl></div>
                  本文介绍了如何使用 javax.mail 设置或更改 SMTP 消息 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在使用 javax.mail 发送邮件时设置 SMTP 消息 ID.我的邮件服务器报告如下内容:

                  How can I set the SMTP message-id while sending mails with javax.mail. My mail server is reporting something like this:

                  1 <= me@domain.com H=mail (host) [192.168.1.4] P=esmtp S=142014
                       id=2043289758.9.1322829290422.JavaMail.thor@developer.local
                  2 => sombodey@else R=dnslookup T=remote_smtp H=mx00.t-online.de [194.25.134.8]
                  3 Completed
                  

                  我想在发送之前设置 id=2043289758.9.1322829290422.JavaMail.thor@developer.local.这可能吗?它创建的电子邮件是这样的:

                  I want to set the id=2043289758.9.1322829290422.JavaMail.thor@developer.local before sending it. Is this possible? The email it created like this:

                  Properties props = System.getProperties();
                  props.put("mail.smtp.host", "192.168.1.4");
                  Session session = Session.getDefaultInstance(props, null);
                  session.setDebug(false);
                  Message msg = createMsg();
                  Transport.send(msg);
                  

                  推荐答案

                  相信这一段JavaMail 常见问题解答 回答您的问题:

                  I believe this section of the JavaMail FAQ answers your question:

                  问:我为我的新消息的 Message-ID 标头设置了一个特定值,但是当我发送此消息时,标头被重写.

                  Q: I set a particular value for the Message-ID header of my new message, but when I send this message that header is rewritten.

                  答: 在调用 saveChanges 方法时会为 Message-ID 字段设置一个新值(通常在消息被已发送),覆盖您自己设置的任何值.如果您需要设置您的拥有 Message-ID 并保留它,您必须创建自己的MimeMessage 子类,覆盖 updateMessageID 方法并使用这个子类的实例.

                  A: A new value for the Message-ID field is set when the saveChanges method is called (usually implicitly when a message is sent), overwriting any value you set yourself. If you need to set your own Message-ID and have it retained, you will have to create your own MimeMessage subclass, override the updateMessageID method and use an instance of this subclass.

                  class MyMessage extends MimeMessage {
                      ...
                  
                      protected void updateMessageID() throws MessagingException {
                    setHeader("Message-ID", "my-message-id");
                      }
                      ...
                  }
                  

                  这篇关于如何使用 javax.mail 设置或更改 SMTP 消息 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                    1. <legend id='1FNN3'><style id='1FNN3'><dir id='1FNN3'><q id='1FNN3'></q></dir></style></legend>
                        <tbody id='1FNN3'></tbody>

                      <small id='1FNN3'></small><noframes id='1FNN3'>

                        <bdo id='1FNN3'></bdo><ul id='1FNN3'></ul>

                        <tfoot id='1FNN3'></tfoot>
                          <i id='1FNN3'><tr id='1FNN3'><dt id='1FNN3'><q id='1FNN3'><span id='1FNN3'><b id='1FNN3'><form id='1FNN3'><ins id='1FNN3'></ins><ul id='1FNN3'></ul><sub id='1FNN3'></sub></form><legend id='1FNN3'></legend><bdo id='1FNN3'><pre id='1FNN3'><center id='1FNN3'></center></pre></bdo></b><th id='1FNN3'></th></span></q></dt></tr></i><div id='1FNN3'><tfoot id='1FNN3'></tfoot><dl id='1FNN3'><fieldset id='1FNN3'></fieldset></dl></div>