diff --git a/src/main/java/org/subethamail/smtp/server/SMTPServer.java b/src/main/java/org/subethamail/smtp/server/SMTPServer.java index 0bc656dd5..103122ae3 100644 --- a/src/main/java/org/subethamail/smtp/server/SMTPServer.java +++ b/src/main/java/org/subethamail/smtp/server/SMTPServer.java @@ -6,6 +6,7 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -163,14 +164,9 @@ public SMTPServer(MessageHandlerFactory msgHandlerFact, AuthenticationHandlerFac this.executorService = Executors.newCachedThreadPool(); } - try - { - this.hostName = InetAddress.getLocalHost().getCanonicalHostName(); - } - catch (UnknownHostException e) - { - this.hostName = UNKNOWN_HOSTNAME; - } + Map map = System.getenv(); + + this.hostName = map.getOrDefault("COMPUTERNAME", map.getOrDefault("HOSTNAME", UNKNOWN_HOSTNAME)); this.commandHandler = new CommandHandler(); }