Is it possible to change the postfix message-id?
Solution 1:
Since no one gave you a solution on how to have postfix insert a message-id that reflects your domain and I had the same issue, I figured I would share how I was able to have postfix do so:
-
Add to the end of
/etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks
-
Insert a replace string in
header_checks
/Message-Id:\s+<(.*?)@hostname>/ REPLACE Message-Id: <[email protected]>
-
Run postmap
postmap /etc/postfix/header_checks
-
Restart postfix
service postfix restart
Solution 2:
Instead of trying to rewrite the message ID in postfix, why not just have javamail generate the correct MessageID from the start. You can change how javamail generates MessageID by subclassing MimeMessage
and providing a new updateMessageID
method
Solution 3:
Why do you want to do this? As @BenPilbrow pointed out, the message-id is next to meaningless. Pretty much the only thing that will use it is a threading e-mail client.
As @stew pointed out, you can just emit an email with a proper message ID in the first place.
Finally, the postfix solution is to change the value of the $myhostname, as this is what postfix uses after the @ symbol when it creates message ids.