How to Reliably Send WordPress Enquiry Emails
Contents
Traditionally, WordPress uses a basic out-of-the-box PHP function (wp_mail() / PHP Mailer) to send form notifications. This relies on the website’s hosting server to route the emails.
However, modern, premium email platforms like Microsoft Office 365 and Google Workspace have incredibly strict security protocols. They do not easily allow external applications (like your web server) to “spoof” their domains or send mail through them without complex configurations (like setting up Azure Apps or Workspace SMTP Relays). For many developers and clients, configuring these relays is overly complicated, out of scope, and prone to breaking.
Instead of fighting with Office 365 or Google Workspace, the easiest and most reliable method is to use a secondary domain with basic email hosting (such as DirectAdmin) to act as a dedicated SMTP sending server.
For this tutorial, we are using DreamIT Host, managed via DirectAdmin. Clients can request DirectAdmin credentials to access this panel.
mail@creativus-sites.com).Before connecting it to a website, ensure the inbox actually works. Log into Webmail (Roundcube) at https://cp53.hosting-cloud.net/roundcube/ and send a quick test email.
You will need your server’s specific configuration details to connect WordPress. You can generate these via https://mail-settings.hosting-cloud.net/.
You will need the Outgoing Server Settings (SSL), which typically look like this:
mail@creativus-sites.commail.creativus-sites.com465 (Implicit SSL) or 587 (STARTTLS)To ensure your emails aren’t flagged as spam, your DNS records must be configured correctly. Note: If your DNS is hosted externally (e.g., Cloudflare), you must add these records there, not just in DirectAdmin.
x._domainkey) instead of the root domain @.Before touching WordPress, verify your server is broadcasting correctly.
250 OK / Authentication succeeded response.By default, WordPress cannot connect to external SMTP servers. You need a dedicated plugin:
This is where most setups fail. The “From Email” address in your plugin settings must exactly match the domain of the SMTP account you just created.
mail@creativus-sites.com, your “From Email” must be mail@creativus-sites.com. If you try to send the email “From” the client’s primary domain (e.g., info@clientdomain.com), Google and Office 365 will flag it as spoofing and block the email.This is caused by the “Local Routing Trap.” If your website is hosted on the same server as your DNS, the server assumes it is responsible for handling your domain’s email locally. If your actual inboxes are hosted externally (like Office 365 or Google Workspace), your server looks for a local inbox, fails, and throws this error.
The Fix: Go into your hosting control panel (e.g., DirectAdmin or cPanel), find the MX Records / Email Routing section, and uncheck the setting that says “Use this server to handle my e-mails” (or set it to “Remote Mail Exchanger”). This forces the server to route mail out to the internet.
You are likely violating the Domain Alignment rule. For email authentication to pass, the “From Email” address used in your WordPress form/plugin must exactly match the domain of the authenticated SMTP server.
The Fix: If you set up your SMTP server on mail@secondary-domain.com, your WordPress plugin’s “From Email” setting must also be mail@secondary-domain.com. Check the “Force From Email” box in your plugin settings to prevent other plugins from overriding this.
If you use Cloudflare for DNS, its default proxy (the “orange cloud”) only supports HTTP/HTTPS web traffic. It will block standard email ports like 465, 587, and 993.
The Fix: Go to your Cloudflare DNS settings and ensure any A or CNAME records related to email (e.g., mail, smtp, pop) are set to DNS Only (Grey Cloud).
DKIM public keys are very long (often 2048-bit). Standard DNS rules (RFC 1035) dictate that text strings cannot exceed 255 characters. Your DNS provider might automatically split the key into two quoted chunks (e.g., "chunk1" "chunk2"). This is perfectly normal and healthy.
The Fix: If you are getting an invalid error, make sure you didn’t accidentally copy/paste extra spaces between the quotation marks when setting up your DNS. Also, ensure you are testing via a proper WordPress SMTP plugin (like WP Mail SMTP) rather than a raw command-line tool, as raw tools can strip necessary headers and break the cryptographic seal.