Title: Empty Hostname
Last modified: November 26, 2025

---

# Empty Hostname

 *  Resolved [Martin Blumenfeld](https://wordpress.org/support/users/monkeypress/)
 * (@monkeypress)
 * [6 months, 2 weeks ago](https://wordpress.org/support/topic/empty-hostname-2/)
 * I was looking at our email logs and found that a bunch of messages were reporting
   the error “” does not match the expected structure for a DNS hostname, ” does
   not appear to be a valid URI hostname, ” does not appear to be a valid local 
   network name
 * In the /post-smtp/Postman/PostmanUtils.php file there’s a function called “getServerName”
   on line 484 that tries to get the server name from: $_SERVER[‘SERVER_NAME’]. 
   The first if statement checks if $_SERVER exists and if it has a SERVER_NAME 
   key, but it doesn’t check if the key actually has a value. In our case our server
   wasn’t setting the SERVER_NAME variable. This sounds like a pretty common issue.
   There’s a very similar function called “postmanGetServerName” on line 403 that
   also looks for the HTTP_HOST key, which did exist on our server. As a quick test
   fix I added “and $_SERVER[‘SERVER_NAME’]” to line 487. That change was able to
   get our emails going again. Have you seen a similar issue on other sites?

Viewing 1 replies (of 1 total)

 *  Plugin Support [M Aqib Khan](https://wordpress.org/support/users/aqibkhan9/)
 * (@aqibkhan9)
 * [6 months, 2 weeks ago](https://wordpress.org/support/topic/empty-hostname-2/#post-18735226)
 * Hello [@monkeypress](https://wordpress.org/support/users/monkeypress/) ,
 * Thank you for sharing your findings in such detail, your analysis is very helpful,
   and I appreciate the time you took to investigate the behavior.
 * Regarding the issue you observed with `$_SERVER['SERVER_NAME']` being present
   but empty, we have not encountered this scenario on other customer sites so far.
   In typical environments, `SERVER_NAME` is populated consistently, as it’s part
   of the standard variables provided by most web servers.
 * Your case appears to be specific to the configuration of your hosting environment,
   where `SERVER_NAME` is defined but not assigned a value. This isn’t common, but
   it can certainly happen in certain setups, especially behind proxies or custom
   server stacks.
 * Your temporary fix of adding a check for a non-empty `SERVER_NAME` is logical
   and aligns with the fallback approach used in `postmanGetServerName()`. Since`
   HTTP_HOST` was available, that condition helped restore normal functionality.
 * I appreciate you bringing this to our attention. While it doesn’t reflect a widespread
   issue, your feedback will help us improve the robustness of this function to 
   better handle atypical server configurations.
 * Warm regards,
   Support Team – WP Experts

Viewing 1 replies (of 1 total)

The topic ‘Empty Hostname’ is closed to new replies.

 * ![](https://ps.w.org/post-smtp/assets/icon-128x128.gif?rev=3209655)
 * [Post SMTP – Complete Email Deliverability and SMTP Solution with Email Logs, Alerts, Backup SMTP & Mobile App](https://wordpress.org/plugins/post-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/post-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-smtp/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [M Aqib Khan](https://wordpress.org/support/users/aqibkhan9/)
 * Last activity: [6 months, 2 weeks ago](https://wordpress.org/support/topic/empty-hostname-2/#post-18735226)
 * Status: resolved