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?
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.
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.