• I’m currently having trouble with the Post SMTP plugin on WordPress in combination with Office 365. We’re using the smtp.office365.com settings (and we have verified that the account details we have are correct and allow login to the Office 365 account), and each test email we try to send comes with the following 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

    We have tried configuring this for port 587 and for port 25.

    HostName: 
    OS: Linux london-drainage 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64
    PHP: Linux 7.0.13-0ubuntu0.16.04.1 en_US.UTF-8
    PHP Dependencies: iconv=Yes, spl_autoload=Yes, openssl=Yes, sockets=Yes, allow_url_fopen=Yes, mcrypt=Yes, zlib_encode=Yes
    WordPress: 4.9.8 en_US UTF-8
    WordPress Theme: X – Child Theme
    WordPress Plugins: 404page - your smart custom 404 error page, Contact Form 7 Google Analytics Integration, Contact Form 7 Modules: Hidden Fields, Contact Form 7, Cornerstone, Duplicator, Flamingo, Google Analytics for WordPress by MonsterInsights, Attercopia London Drainage Search, Page/Post Content Shortcode, Post SMTP, Redirection, Simple Custom CSS, UberMenu 3 - The Ultimate WordPress Mega Menu, UpdraftPlus - Backup/Restore, WonderPlugin Tabs, Yoast SEO, WP Fastest Cache, Smush, Contact Form 7 Redirection
    WordPress wp_mail Filter(s): wp_staticize_emoji_for_email
    WordPress phpmailer_init Action(s): wpcf7_phpmailer_init
    Postman: 1.9.4
    Postman Sender Domain (Envelope|Message): london-drainage.co.uk | london-drainage.co.uk
    Postman Prevent Message Sender Override (Email|Name): No | No
    Postman Active Transport: SMTP (smtp:tls:login://smtp.office365.com:25)
    Postman Active Transport Status (Ready|Connected): Yes | Yes
    Postman Deliveries (Success|Fail): 0 | 0

    Any suggestions or recommendations would be very helpful.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 19 total)
  • Strange, where do you host?

    Thread Starter csreid

    (@csreid)

    I’m hosting with Digital Ocean; I have just done a test using a temporary Gmail account set up to use OAuth and that’s also giving the same error.

    There is an error getting your hostname

    What do you get when you type in the command line:
    hostname

    Thread Starter csreid

    (@csreid)

    Hello again – I’m getting the hostname london-drainage at the moment, just checking the hosts file to see if there’s a reason for it showing that in preference to the full domain name.

    Thread Starter csreid

    (@csreid)

    I’ve now updated the hostname to a full URI and unfortunately I am still seeing

    '' 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

    If you did ok you should see your hostname in the diagnostic test.
    Paste it here

    Thread Starter csreid

    (@csreid)

    HostName: 
    OS: Linux london-drainage.co.uk 4.4.0-133-generic #159-Ubuntu SMP Fri Aug 10 07:31:43 UTC 2018 x86_64
    PHP: Linux 7.0.13-0ubuntu0.16.04.1 en_US.UTF-8
    PHP Dependencies: iconv=Yes, spl_autoload=Yes, openssl=Yes, sockets=Yes, allow_url_fopen=Yes, mcrypt=Yes, zlib_encode=Yes
    WordPress: 4.9.8 en_US UTF-8
    WordPress Theme: X – Child Theme
    WordPress Plugins: 404page - your smart custom 404 error page, Contact Form 7 Google Analytics Integration, Contact Form 7 Modules: Hidden Fields, Contact Form 7, Cornerstone, Duplicator, Flamingo, Google Analytics for WordPress by MonsterInsights, Attercopia London Drainage Search, Page/Post Content Shortcode, Post SMTP, Redirection, Simple Custom CSS, UberMenu 3 - The Ultimate WordPress Mega Menu, UpdraftPlus - Backup/Restore, WonderPlugin Tabs, Yoast SEO, WP Fastest Cache, Smush, Contact Form 7 Redirection
    WordPress wp_mail Filter(s): wp_staticize_emoji_for_email
    WordPress phpmailer_init Action(s): wpcf7_phpmailer_init
    Postman: 1.9.4
    Postman Sender Domain (Envelope|Message): london-drainage.co.uk | london-drainage.co.uk
    Postman Prevent Message Sender Override (Email|Name): No | No
    Postman Active Transport: SMTP (smtp:tls:login://smtp.office365.com:587)
    Postman Active Transport Status (Ready|Connected): Yes | Yes
    Postman Deliveries (Success|Fail): 0 | 0

    I want to make clear we are stepping out from the plugin support scope, you have an issue with server configuration. I’m interested to understand the issue so I will continue trying to solve it with you.

    Please verify you have this line in your hosts file located at /etc/hosts:

    
    127.0.1.1 london-drainage.co.uk london-drainage
    127.0.0.1 localhost
    

    if you want to know your full hostname you can type
    hostname -f

    • This reply was modified 6 years, 3 months ago by yehudah.
    Thread Starter csreid

    (@csreid)

    Thank you for your assistance so far; I have raised a support ticket with our hosting partners as well to see if we can resolve this.

    Yes, we do have those two lines exactly as entered in our /etc/hosts file.

    Can you restart the server, and paste the first line of the diagnostic test,?

    Thread Starter csreid

    (@csreid)

    What I’m currently seeing on the Diagnostic test is:

    HostName: 
    OS: Linux london-drainage.co.uk 4.4.0-133-generic #159-Ubuntu SMP Fri Aug 10 07:31:43 UTC 2018 x86_64

    The hostname -f command through SSH is showing
    london-drainage.co.uk

    Not sure if it helps, but the server is using NGINX and this is the first time we’ve encountered this particular issue with Post SMTP using the same server setup.

    Thread Starter csreid

    (@csreid)

    I’ve been discussing this with our hosting partners, and they have confirmed that they are not seeing any problems on the platform or server-side based on the information we’ve provided them (the same as we’ve provided here) – and that the hosting server has a valid rDNS record matching the server’s hostname of https://www.london-drainage.co.uk (they did recommend we update this to https://www.london-drainage.co.uk as a FQDN).

    Hi,

    Please upload this PHP file to the root of your website and run it.
    Update what was the result here:

    
            echo getServerName(); 
    
    	function getServerName() {
            $result = 'localhost.localdomain';
            
            if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) {
                $result = $_SERVER['SERVER_NAME'];
            } elseif (function_exists('gethostname') and gethostname() !== false) {
                $result = gethostname();
            } elseif (php_uname('n') !== false) {
                $result = php_uname('n');
            }
    
    		if ( $result !== 'localhost.localdomain' ) {
    			// get the current result ip
    			$ip = gethostbyname($result);
    
    			// dns query failed
    			if ( $ip == $result ) {
    				return $result;
    			}
    
    			// get the current ip hostname - reverse dns
    			$host = gethostbyaddr($ip);
    
    			// dns query failed
    			if ( $host == $ip ) {
    				return $result;
    			}
    
    			// if hostname is not equal to the result set the ptr
    			if ( $result !== $host ) {
    				$result = $host;
    			}
    		}
    
            return $result;
    	}
    
    Thread Starter csreid

    (@csreid)

    What I’m seeing on running that code is a blank page, with no visible result displayed.

    Try this:

    
    <?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    
    echo getServerName(); 
    
    function getServerName() {
    $result = 'localhost.localdomain';
    
    if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) {
        $result = $_SERVER['SERVER_NAME'];
    } elseif (function_exists('gethostname') and gethostname() !== false) {
        $result = gethostname();
    } elseif (php_uname('n') !== false) {
        $result = php_uname('n');
    }
    
    	if ( $result !== 'localhost.localdomain' ) {
    		// get the current result ip
    		$ip = gethostbyname($result);
    
    		// dns query failed
    		if ( $ip == $result ) {
    			return $result;
    		}
    
    		// get the current ip hostname - reverse dns
    		$host = gethostbyaddr($ip);
    
    		// dns query failed
    		if ( $host == $ip ) {
    			return $result;
    		}
    
    		// if hostname is not equal to the result set the ptr
    		if ( $result !== $host ) {
    			$result = $host;
    		}
    	}
    
           return $result;
    }
Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Post SMTP – Office 365 connection issue’ is closed to new replies.