2

When I send email from my application using the default WildFly mail session, the auto-generated message ID gives away that my server is WildFly:

Message-ID: <524672585.11.1429091886393.JavaMail.wildfly@myserver.example.com>

For security reasons, I'd like to suppress or override the wildfly substring in the message ID.

Is there a configuration element or a system property to do that?

Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63

2 Answers2

0

Answering my own question: The wildfly part of the message ID corresponds to the value of the user.name system property. My server happens to be running under a Linux user account named wildfly.

So one option would be to use a different user account. Alternatively, simply passing -Duser.name=foo to the WildFly start script is enough to change the message ID.

Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63
  • You can also subclass MimeMessage and override the [updateMessageID](https://javamail.java.net/nonav/docs/api/javax/mail/internet/MimeMessage.html#updateMessageID()) method. – Bill Shannon Apr 15 '15 at 18:09
  • 1
    See also: [Bug 6496 -Message-Id leaks current user/hostname of the Java process](https://kenai.com/bugzilla/show_bug.cgi?id=6496). – jmehrens Apr 15 '15 at 20:17
  • @BillShannon: Yes, I'm aware of that, but i was hoping to avoid changing my code, that's why I asked about _configuration_. – Harald Wellmann Apr 15 '15 at 21:14
  • @jmehrens: Thanks for the pointer - the bug is marked as resolved for javax.mail 1.5.3, but unfortunately there is no release with that version, at least not on Maven Central. – Harald Wellmann Apr 15 '15 at 21:23
  • Check the website again. 1.5.3 was just released. – jmehrens Apr 16 '15 at 13:16
0

Upgrade to JavaMail 1.5.3. That official release has Bug 6496 -Message-Id leaks current user/hostname of the Java process marked as resolved.

Otherwise, the Message-ID computation uses the InternetAddress.getLocalAddress method which is including the username. You can set the mail.from session property to override including the O/S user name.

public static void main(String[] args) throws Exception {
        Properties props = new Properties();
        props.put("mail.from", "------@bar.baz");
        Session s = Session.getInstance(props);
        MimeMessage m = new MimeMessage(s);
        m.addFrom(InternetAddress.parse("foo@bar.baz"));
        m.setText("");
        m.saveChanges();
        m.writeTo(System.out);
}

Which will output something like:

From: foo@bar.baz
Message-ID: <1688376486.0.1429814480627.JavaMail.------@bar.baz>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

If you are using the default session you can just add 'mail.from' to the system properties.

jmehrens
  • 10,580
  • 1
  • 38
  • 47
  • That does not answer the question. The answer appears to be no. And you can't trivially upgrade a container-level library. However, this upgrade will be included in WildFly 9.0.0.CR1 (see [WFLY-4536](https://issues.jboss.org/browse/WFLY-4536)). – Harald Wellmann Apr 23 '15 at 18:02
  • Edited the answer. I think the 'mail.from' property does what you need. – jmehrens Apr 23 '15 at 18:49