title: How to prevent mail from Wordpress website from being flagged as spam on Exchange online server
body: <p>I have a website; let's call it abc.com. It's e-mail is handled by Office365. I recently migrated it from a Sharepoint environment to a different webhost (GoDaddy). I have tried using the WP Mail SMTP plugin option to send e-mails, but it fails to send.</p>
  
  <p>My settings are:</p>
  
  <pre><code>smtp: smtp.office365.com
  port: 587
  encryption: use TLS
  authentication: use smtp
  </code></pre>
  
  <p>Sending fails with the error:</p>
  
  <pre><code>SMTP ERROR: Failed to connect to server: Connection refused (111)
  </code></pre>
  
  <p>Using the default wp mail with the settings below works to send to e-mail addresses <em>outside</em> the domain, but messages get flagged as spam on addresses within the domain.</p>
  
  <pre><code>header = 'From: '.get_option('blogname').' &lt;wordpress@abc.com&gt;'
  </code></pre>
  
  <p>I have e-mail routing set to Remote Mail Exchanger. I've tried adding the address <code>wordpress@abc.com</code> to Exchange's allowed list/whitelist, and I even tried adding the host IP to trusted IPs on the server - but it still doesn't work.</p>