How to Reliably Send WordPress Enquiry Emails

The Problem

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.

The Solution

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.


Phase 1: Server & Email Setup

Step 1: Create the Sending Email Account

  1. Access your DirectAdmin panel.
  2. Navigate to Email Manager > E-mail Accounts.
  3. Create a new email account specifically for sending website notifications (e.g., mail@creativus-sites.com).
  4. Tip: Keep a secure record of these passwords. If an email password is changed here, it must be updated on every connected WordPress site.

Step 2: Verify the Inbox

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.

Step 3: Gather SMTP Settings

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:

  • Username: mail@creativus-sites.com
  • Password: Your email password
  • Server: mail.creativus-sites.com
  • Port: 465 (Implicit SSL) or 587 (STARTTLS)

Phase 2: DNS Authentication (The Most Critical Phase)

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.

Step 4: Configure the Big Three Authenticators

  • SPF (Sender Policy Framework): Authorizes your web server to send emails. It is mandatory. (Tool: EasyDMARC SPF Generator).
  • DKIM (DomainKeys Identified Mail): Cryptographically signs your emails to prevent tampering.
    • Crucial Setup Note: Ensure the TXT record name uses the exact selector provided by your host (e.g., x._domainkey) instead of the root domain @.
  • DMARC (Domain-based Message Authentication): Tells receiving servers what to do if an email fails SPF or DKIM. To avoid getting flooded with XML email reports, use a free management tool like Cloudflare DMARC Management or EasyDMARC to absorb the logs.

Phase 3: External Validation

Step 5: Test the Raw SMTP Connection

Before touching WordPress, verify your server is broadcasting correctly.

  1. Go to SMTP-Test.com.
  2. Input your credentials from Step 3.
  3. Check the logs to ensure you receive a 250 OK / Authentication succeeded response.

Step 6: Test Deliverability & Spam Score

  1. Go to Mail-Tester.com.
  2. Send an email from your Webmail (Roundcube) to the provided testing address.
  3. Aim for a 10/10 score to verify your SPF, DKIM, and DMARC are perfectly aligned.

Phase 4: WordPress Integration

Step 7: Install an SMTP Plugin

By default, WordPress cannot connect to external SMTP servers. You need a dedicated plugin:

  • WP Mail SMTP: Highly recommended, user-friendly, great logging (Paid options available).
  • FluentSMTP: Powerful and free, but no official support (Best for advanced users).

Step 8: Configure the Plugin

  1. Select “Other SMTP” as your mailer.
  2. Input your Host, Port, Username, and Password from Step 3.

Step 9: Enforce “Domain Alignment” (Do Not Skip)

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.

  • Example: If your SMTP account is 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.
  • Check the “Force From Email” box in your plugin settings to ensure forms don’t override this rule.

Step 10: Final Testing & Monitoring

  1. Use the “Email Test” tab inside your SMTP plugin to send a test email to your own inbox.
  2. Submit a live form on the website to ensure the routing works seamlessly.
  3. Ongoing Maintenance: Keep an eye on password changes and occasionally review your DMARC reports to ensure deliverability remains high.

Troubleshooting Common SMTP & Email Deliverability Issues

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.