New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
SMTP and APIUpdated 15 Oct 2026

WordPress and Website Contact Form Email: How to Send Reliably Through SMTP

Website emails such as contact form notifications, order confirmations and password resets often vanish or land in spam because the site sends them with the default PHP mail function. This guide explains why, and how to route them through authenticated SMTP with the right From address, Reply-To, DNS records, safe credential storage, spam protection and testing.

EB
Written by Ethan Brooks
Transactional Email Specialist
Reviewed by Valentina Reyes
  • Published18 Aug 2026
  • Read time12 min
  • Length2,525 words
Share this guide

Reliable WordPress SMTP setup starts with one idea: stop sending site mail the easy way. A visitor fills in your contact form, sees a friendly thank-you message, and you never receive anything. Or a customer places an order and the confirmation lands in spam. These are some of the most common support questions we see from site owners, and nearly all of them come down to one thing: the website sends mail the easy way, with the default PHP mail function or the web server mail system, instead of through an authenticated SMTP connection. This guide explains why that fails, and how to set up WordPress SMTP or the equivalent mail settings in another CMS or framework so that form notifications, order emails and password resets arrive reliably.

2standard secure ports: 587 and 465
3DNS authentication records: SPF, DKIM, DMARC
1fixed From address for site mail
8steps in the setup checklist below

Why default website mail ends up in spam or disappears

WordPress calls a function named wp_mail, and by default that function relies on the PHP mail function, which passes the message to a mail program on the same server. Other CMSs and frameworks have similar defaults. This is convenient, because it needs no settings, but it has weaknesses that matter a great deal to modern mailbox providers.

WeaknessWhat happensWhat fixes it
No authentication to a mail platformThe message appears from nowhere, with no login behind it and no accountable senderSubmit mail over SMTP with a username and password
Shared hosting IP addressesYour mail leaves from an address shared with many other sites, some of which send spam, so its reputation is mixedSend from the infrastructure of a dedicated sending platform
From address mismatchThe From domain does not match the server that sent the message, or it is an address like wordpress@ followed by the server nameUse a From address on your verified domain
Missing SPF or DKIM for the sending pathReceiving servers cannot confirm the message is allowed to use your domainPublish the records for your sending platform
No visibilityThe site reports success when it only handed the message to the local mail programLog messages and check platform events
Server limits and blocksThe host throttles or silently drops outgoing mail, especially in burstsMove to a purpose-built delivery path

Mailbox providers have also raised their expectations. Messages without proper authentication and a consistent sender identity are more likely to be filtered or rejected, as we describe in the bulk sender requirements checklist. Even a small site that sends a few messages a day benefits from doing the basics properly.

How SMTP sending works for a website

With SMTP configured, your site no longer hands mail to the local server. It opens a connection to your sending platform, logs in, and submits the message there. The platform then delivers it to the recipient with its own infrastructure and signs it with the keys for your domain. The two parts that you control are the connection settings and the identity of the message.

Connection settings

  • Host. The SMTP server name for your account. Use the value shown in your MigoSMTP account. Do not guess it or copy one from an example.
  • Port and encryption. Port 587 is the message submission port defined in RFC 6409. It normally starts unencrypted and upgrades the connection with STARTTLS. Port 465 uses implicit TLS, where encryption starts immediately, and RFC 8314 recommends it for mail submission. Choose one pair and make sure the encryption setting matches the port.
  • Authentication. Turn it on, and enter the username and password or key that your sending platform shows for SMTP.
  • Certificate checks. Leave verification of the server certificate switched on. Turning it off hides a real problem and weakens the connection.

Our guide to SMTP ports, TLS and authentication explains each of these choices in more depth, and SMTP or API helps you decide whether a plugin that talks to an HTTP API would suit your site better.

A generic configuration example

The names differ between plugins and frameworks, but the information is always the same. This example shows the shape of an environment-based configuration, using placeholders. Replace each one with the real value from your account.

# Example environment variables for a site or framework
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_ENCRYPTION=starttls
MAIL_USERNAME=your-smtp-username
MAIL_PASSWORD=your-smtp-password
MAIL_FROM_ADDRESS=notifications@example.com
MAIL_FROM_NAME=Example Company

// WordPress style: some SMTP plugins can read constants like these
// from wp-config.php instead of storing them in the database.
// Constant names vary, so check your plugin documentation.

Set up your From address and Reply-To correctly

This is where most contact form problems start. A form usually has a visitor name and email field, and the lazy way to build the notification is to send the message from the visitor address to yourself. It looks logical, and it is wrong.

From: a fixed address on your own domain

The From address tells the receiving server who is responsible for the message. It must be an address on a domain you control and have verified with your sending platform, such as notifications at your own domain. If the From domain is the visitor domain, your platform cannot sign for it, SPF and DKIM will not align, and a DMARC policy at that domain may cause the message to be rejected or quarantined. It is also a form of spoofing, which is exactly what authentication is designed to stop. See how to verify your sending domain for the verification steps.

Reply-To: the visitor address

Put the visitor address in the Reply-To header. When you press reply in your mail app, the answer goes to the visitor, while the message itself is still sent honestly from your domain. Most contact form plugins and frameworks have a setting for Reply-To, and some use it by default. Check the setting once, then send a test and confirm it in the headers.

A good rule: From says who sent the message. Reply-To says where answers should go. Never use the visitor address in the first when you mean the second.

Authenticate the sending domain

SMTP login alone does not make a message trustworthy. Receiving servers look at the domain records. Publish the SPF and DKIM records that your platform provides for the domain in your From address, and add a DMARC record to say what should happen to messages that fail. Start with a monitoring policy and tighten it later. The full procedure is in how to authenticate a sending domain.

  • If your domain already sends mail from a company mailbox service, add the new sending source to the existing SPF record instead of creating a second SPF record.
  • Use the same domain, or a subdomain you have verified, in the From address of every form and notification.
  • After changing DNS, send a test and confirm in the headers that SPF and DKIM pass and align.

WooCommerce and other transactional email

Shop and membership plugins send a lot more than contact form notifications: order confirmations, shipping updates, invoices, account emails and password resets. These are transactional messages that a customer is waiting for, so delays and spam placement cost real money and support time. Once SMTP is configured at the site level, these plugins use it automatically, because they send through the same mail function.

  • Set one consistent From name and address in the shop email settings, and make it match the verified domain.
  • Test each important template at least once: new order, processing, completed, refund and password reset.
  • Keep these messages plain, fast and relevant. Avoid mixing promotions into receipts.
  • If you also send newsletters or campaigns, consider keeping them on a separate stream or subdomain so that marketing complaints do not harm order emails. See transactional versus marketing streams.

Stop bots from abusing your forms

Once your site can send reliably, it can also be abused more effectively. A contact form that accepts any text and sends it to any address is a free relay for spammers, and the complaints that follow will land on your domain. Plan for this from the start.

ProtectionHow it helpsNotes
CAPTCHA or invisible challengeSeparates people from simple bots before a message is createdChoose one that respects your visitors and accessibility needs
Honeypot fieldA hidden field that people leave empty and bots fill inCheap and unobtrusive; reject submissions that fill it
Server-side rate limitingCaps submissions per address or session per minuteWorks even when a bot skips the page and posts directly
Fixed recipient and FromThe form can only send to you, from your addressNever accept a recipient or From value from the request
Header injection checksRejects line breaks in name, subject and email fieldsMost modern frameworks and plugins do this, but verify
Content limitsLimits message length and number of linksReduces junk and keeps notifications readable

Store credentials safely

An SMTP password is a key to your sending reputation. If someone gets it, they can send mail as your domain. Many SMTP plugin screens store the password in the site database, which means it appears in database backups, staging copies and exports. Where your plugin allows it, prefer one of these approaches.

  • Define the settings as constants in wp-config.php, if your plugin supports that. Check its documentation for the exact names, because they differ.
  • In frameworks, use environment variables or a secrets manager, and keep the env file out of version control.
  • Restrict file permissions on configuration files, and never place credentials in theme or plugin files that are shared or committed.
  • Use separate credentials for each site, so you can revoke one without breaking the others.
  • Rotate the password if staff leave, a backup is exposed or you suspect leakage. Our guide to API key security and rotation covers storage and leak response in more detail.

Test, log and monitor

  1. Use the test email function in your SMTP plugin or a simple script, and send to a mailbox you own.
  2. Open the message source and check the From, Reply-To and authentication results. If you are not sure how to read them, see how to read email headers.
  3. Submit the real contact form with a fake visitor address that you control, and verify that Reply-To is the visitor.
  4. Enable mail logging for a period, so failed and successful sends are recorded. Keep logs for a limited time and avoid storing message bodies that contain personal data longer than needed.
  5. Check activity data in your sending platform after each test, so you can compare what the site reports with what the platform delivered.

Common errors and what to do

SymptomLikely causeWhat to check
Authentication failedWrong username or password, or revoked credentialsRetype the values, check for spaces, confirm they are the SMTP credentials, rotate if needed
Connection timed outThe host blocks the outbound port, or a firewall is in the wayTest another permitted port or an HTTP API method; ask the host which ports are open
Connection refusedWrong host or portCompare with the values shown in your MigoSMTP account
Certificate or SSL errorEncryption mode does not match the port, outdated server certificates, or a wrong host nameMatch 587 with STARTTLS and 465 with implicit TLS; update the server CA bundle; use the exact host name
Sender or domain rejectedThe From domain is not verified or does not match the accountVerify the domain and use an address on it
Sent in the log but not receivedAccepted by the platform but filtered or bounced laterCheck platform events, bounce reasons and the recipient spam folder
Works in testing, fails for some formsA form sets its own From or recipientReview each form notification setting

For connection and TLS problems in detail, use our SMTP connection and TLS troubleshooting guide.

When your host blocks outbound SMTP

Many hosting companies and cloud providers restrict outbound SMTP, often port 25 and sometimes other ports, to reduce abuse from compromised sites. If connections to your sending platform time out while the credentials are right, you have a few legitimate options.

  1. Ask the host which outbound ports are available and whether they can open the submission port for your account.
  2. Check your MigoSMTP account for any alternative port the platform offers, and test it. Do not assume one exists.
  3. Use a plugin or code that sends through an HTTP API on port 443, which is almost never blocked.
  4. If none of that is possible, consider whether the hosting plan suits a site that sends important mail.

The same ideas on other CMSs and frameworks

Nothing here is specific to WordPress. Whatever you run, the same five decisions apply: the host, the port with its matching encryption mode, the credentials, the From address and the Reply-To handling.

  • Other CMSs usually have a mail or SMTP section in their settings, or an extension for it. Look for fields for host, port, encryption, username and password.
  • PHP frameworks typically read a mail configuration from environment variables, with a mailer setting for SMTP.
  • Node.js, Python, Ruby and Java applications use a mail library that takes the same values in an options object or configuration file.
  • Static sites with a form service still need the service to send from a verified domain. Check which address it uses as From.

A worked example: the contact form that stopped arriving

A small design studio runs a WordPress site with a contact form and a shop. The form notification is sent from the visitor address to the studio inbox using the default mail function. For months this works, then notifications start to vanish. Customers say they never heard back, and some order confirmations land in spam.

The studio checks the headers of a message that did arrive and finds no authentication for the sending path, the server hosts many other sites and the From domain is the visitor domain. They make five changes. They install an SMTP plugin and enter the host, port 587, STARTTLS and credentials from their sending account. They verify their own domain and publish the SPF, DKIM and DMARC records. They set the From address to a fixed address on that domain and move the visitor address to Reply-To. They add a honeypot and a challenge to the form. They move the password into wp-config.php using the constants their plugin supports. After testing each form and each shop template, notifications arrive within seconds, and replies go straight to the visitor. The scenario is illustrative, but these are the usual causes and fixes.

A short checklist

  1. Site mail goes through SMTP, not the default mail function.
  2. Host, port and encryption come from your sending account, and they match each other.
  3. The From address is fixed and on a verified domain.
  4. Reply-To holds the visitor address; From never does.
  5. SPF, DKIM and DMARC are published and pass with alignment.
  6. Forms have a CAPTCHA or honeypot, rate limits and fixed recipients.
  7. Credentials live in constants or environment variables, not in code or shared screens.
  8. Logging is on, and every form and shop template has been tested once.

Want your site email to arrive? Tell us which CMS or framework you use and where it is hosted, and we will help you work out the right settings.

Contact support

Further reading and sources

Frequently asked questions

Why do my contact form emails go to spam or never arrive?

Most sites send with the default PHP mail function, which hands the message to the web server with no login, often from a shared hosting IP address and sometimes with a From address that does not match the sending server. Receiving servers see an unauthenticated message and treat it with suspicion. Sending through authenticated SMTP with a From address on your verified domain fixes the common causes.

Which port should I use, 587 or 465?

Both are standard. Port 587 is the message submission port (RFC 6409) and normally starts plain and upgrades with STARTTLS. Port 465 uses implicit TLS, where the connection is encrypted from the first byte (RFC 8314). Use the combination your plugin or framework supports and that your MigoSMTP account lists, and do not mix them, for example by choosing 465 with STARTTLS.

Can I set the visitor email address as the From address?

No. The From address should be on a domain you control and have authenticated. If you put a visitor address there, SPF and DKIM will not align with it, DMARC checks can fail and your own mail may be rejected. Put the visitor address in Reply-To so you can still answer with one click.

What does authentication failed mean?

The server rejected the username or password. Check for typos, trailing spaces, a copied value that was cut short, and whether you are using SMTP credentials rather than your account login if your platform separates them. Also confirm that the credentials have not been rotated or revoked.

My host blocks outbound SMTP. What can I do?

Some hosts and cloud providers block port 25 and sometimes other SMTP ports to limit abuse. Ask the host which ports are open, check whether your sending platform offers an alternative submission port, or send through an HTTP API over port 443 from a plugin or code that supports it. Do not switch to a different host only to bypass a rule without understanding it.

Where should I store the SMTP password?

Outside the database and the code repository where possible. Many WordPress SMTP plugins can read settings from constants defined in wp-config.php, and frameworks read environment variables. Check your plugin documentation for the supported constants. Restrict file permissions and rotate the password if it is ever exposed.

Do I still need SPF, DKIM and DMARC if I use SMTP?

Yes. SMTP with a login proves that you may submit mail to the platform, but receiving servers judge the message by the domain authentication records. Publish the records your platform gives you for your sending domain, and then check that the results pass and align.

How do I stop bots from using my contact form to send mail?

Add a CAPTCHA or an invisible challenge, a honeypot field that humans never fill in, and server-side rate limiting. Validate that fields are not stuffed with line breaks or extra headers, and never let a form choose its own recipient or From address.

How do I know whether a message was really sent?

Enable mail logging in your plugin or application, and also check the activity and event data in your sending platform. A log in the site shows that the site handed the message over, while platform data shows what happened to it afterwards. Both are needed to find where a message was lost.

Topics#wordpress#smtp#contact form#woocommerce#php mail#wp_mail#from address#reply-to#spf#dkim#dmarc#cms
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Start free Talk to sales