diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
index 4899c6d22dff806e8bdb5c19cf4998d42ccfeb95_aGdleHQvcGF0Y2hib21iLnB5..1415b78869ebcd0d69b2cf451f346b92e86fae7a_aGdleHQvcGF0Y2hib21iLnB5 100644
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -470,8 +470,9 @@
     return revs
 
 def _msgid(node, timestamp):
-    return '<%s.%d@%s>' % (node, timestamp,
-                           encoding.strtolocal(socket.getfqdn()))
+    hostname = encoding.strtolocal(socket.getfqdn())
+    hostname = encoding.environ.get('HGHOSTNAME', hostname)
+    return '<%s.%d@%s>' % (node, timestamp, hostname)
 
 emailopts = [
     ('', 'body', None, _('send patches as inline message text (default)')),