Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Hosting · Info

WordPress PHP Email Settings Explained: What Each Option Does

WordPress PHP Email Settings Explained: What Each Option Does

Short answer

WordPress sends email through wp_mail(), which uses PHPMailer and PHP's mail() function by default. The php.ini mail settings control the server's mail program, filters set the From address and name, and an SMTP plugin swaps in an authenticated mail server for reliable delivery.

Key takeaways

  • WordPress has no built-in email settings screen.
  • wp_mail() uses PHPMailer and PHP mail() unless SMTP is configured.
  • The SMTP and smtp_port php.ini settings only apply on Windows servers.
  • Change the From address with filters or an SMTP plugin.
  • SPF, DKIM and DMARC matter more than PHP settings for inbox delivery.

What are WordPress PHP email settings?

WordPress PHP email settings are the server and code options that control how WordPress sends mail, from PHP's own mail configuration to the From address, sender name and SMTP connection details.

WordPress does not have an email settings screen of its own. It sends every message, such as password resets and form notices, through a function called wp_mail().

That function uses the PHPMailer library, which by default hands the message to PHP's mail() function. PHP then passes it to the server's mail program.

So the settings that matter live in three places: the server's PHP configuration, WordPress filters in code, and SMTP plugins that change how PHPMailer sends.

SettingWhere it livesWhat it controls
sendmail_pathphp.ini (Linux and macOS servers)Which mail program PHP calls
SMTP and smtp_portphp.ini (Windows servers only)Mail server PHP connects to
sendmail_fromphp.iniDefault sender address in some setups
mail.add_x_headerphp.iniAdds a header naming the sending script
mail.logphp.iniLogs every mail() call to a file
From email and nameWordPress filters or SMTP pluginSender shown to recipients
Content typeWordPress filterPlain text or HTML email
SMTP host, port, encryptionSMTP plugin or phpmailer_initExternal mail server connection

How does WordPress send email by default?

By default, WordPress calls wp_mail(), which builds the message with PHPMailer and sends it through PHP's mail() function on your web server.

The wp_mail() reference shows the function's arguments: recipient, subject, message, headers and attachments. Core features and most plugins use it.

PHP's mail() function then passes the message to the local mail program, usually sendmail or a compatible tool such as Postfix or Exim.

This route needs no setup, which is why it is the default. But messages sent this way are often unauthenticated, so they land in spam or are rejected by providers like Gmail and Outlook.

What do the php.ini mail settings do?

The php.ini mail settings tell PHP which program or server to use for mail(), what default sender to use and whether to log or tag outgoing messages.

The full list is in the PHP mail configuration reference. These are the ones you are most likely to see:

sendmail_path sets the program PHP runs to send mail on Linux and macOS servers. Hosts usually set this for you, and changing it is rarely needed on shared hosting.

SMTP and smtp_port set the mail server and port, but only on Windows servers. On Linux, PHP ignores them, which surprises many site owners who try to edit them.

sendmail_from sets a default From address for mail() on Windows. On Linux, the sender is usually set by the mail program or the message headers.

mail.add_x_header adds an X-PHP-Originating-Script header that names the script and user. Hosts sometimes enable it to trace spam from hacked sites.

mail.log writes a log line for every mail() call. It is useful when you need to prove whether WordPress tried to send a message.

You can check these values with a phpinfo() page or your host's PHP settings screen. Our guide on checking your PHP version shows where to find that screen.

How do you change the From email and sender name?

WordPress sends from wordpress@yourdomain with the name WordPress unless you change it with the wp_mail_from and wp_mail_from_name filters or an SMTP plugin.

The default From address uses your site's domain. If that mailbox does not exist, or your domain's records do not allow your server to send for it, emails are more likely to be flagged.

Developers can add the filters in a small custom plugin. The wp_mail_from filter reference shows how it works.

add_filter( 'wp_mail_from', fn() => '[email protected]' );
add_filter( 'wp_mail_from_name', fn() => 'Example Shop' );

Use an address on your own domain that really exists. Free email addresses from Gmail or Yahoo as the From address tend to fail authentication checks.

Note that the admin email under Settings, then General, described in the General Settings documentation, is where WordPress sends notices to you. It is not the address WordPress sends from.

How do you send HTML email from WordPress?

WordPress sends plain text by default, and the wp_mail_content_type filter or a Content-Type header switches messages to HTML.

Many plugins, including WooCommerce and form builders, already send HTML by setting the header for their own messages. You only need the filter for custom code.

If you set HTML for all mail with a global filter, core emails such as password resets can lose their line breaks. Setting the header per message is safer.

What do SMTP settings change?

SMTP settings tell PHPMailer to send through an authenticated mail server instead of PHP's mail(), which makes delivery far more reliable.

An SMTP plugin, such as WP Mail SMTP, FluentSMTP or Post SMTP, adds a settings screen for these values. Behind the scenes, it uses the phpmailer_init hook to switch PHPMailer into SMTP mode.

The main SMTP fields are:

  • SMTP host, such as your email provider's server name
  • Port, usually 587 for TLS or 465 for SSL
  • Encryption, TLS or SSL to match the port
  • Authentication, normally on, with a username and password
  • From email and name, which the plugin can force on all messages

Many plugins also connect to email APIs from services such as SendGrid, Mailgun, Brevo or Amazon SES. These skip SMTP ports, which helps on hosts that block them.

Our guide on setting up SMTP in WordPress walks through a full setup.

If you want to know more about one popular option, read what WP Mail SMTP is.

Which settings matter most for delivery?

The settings that matter most for inbox delivery are an authenticated sending route, a real From address on your domain and correct SPF, DKIM and DMARC records.

PHP settings alone cannot fix deliverability. Major mail providers check whether the sending server is allowed to send for your domain and whether the message is signed.

Those checks rely on DNS records. Our guide to setting up SPF, DKIM and DMARC explains what each record does.

The PHPMailer project itself recommends sending through SMTP rather than mail() for this reason. Local mail programs on shared servers often have poor reputations.

How can you test your email settings?

Send a test message after every change, then check the inbox, spam folder and the message headers to confirm which route was used.

Most SMTP plugins have an email test tool. Our guide on testing WP Mail SMTP shows how to read the results.

Look at the headers in the received email. They show the sending server and whether SPF, DKIM and DMARC passed.

If nothing arrives at all, check whether your host blocks outgoing mail or SMTP ports. Our guide to WordPress not sending emails covers the most common causes.

Should you change PHP mail settings yourself?

Most site owners should leave php.ini mail settings to the host and use an SMTP plugin instead, because it is safer, portable and does not depend on server access.

Editing php.ini needs server access that shared hosting often does not give. Changes may also be lost when the host updates its PHP configuration.

An SMTP plugin keeps your mail setup inside WordPress, so it moves with the site when you change hosts. That makes it the practical choice for most sites.

Frequently asked questions

Where are email settings in WordPress?

There is no dedicated email settings screen in core WordPress. The admin email under General settings only controls where notices go. To change how mail is sent, use an SMTP plugin or add code that uses the mail filters and hooks.

Why does WordPress send email from wordpress@ my domain?

That is the default From address built from your site's domain. You can change it with the wp_mail_from and wp_mail_from_name filters, or with an SMTP plugin that forces a From address on every message.

Can I set SMTP in php.ini for WordPress?

Only on Windows servers, where PHP reads the SMTP and smtp_port settings. On Linux servers, PHP uses sendmail_path instead and ignores those values. An SMTP plugin is the more reliable way to use an external mail server.

What port should I use for SMTP in WordPress?

Port 587 with TLS is the most common choice, and port 465 with SSL is the main alternative. Use the exact values your email provider lists. Some hosts block outbound SMTP ports, in which case an API-based mailer is a good option.

Why do WordPress emails go to spam?

Messages sent through PHP mail() are usually unauthenticated, and the From address may not match your domain's records. Sending through an authenticated service and adding SPF, DKIM and DMARC records fixes most spam problems.

Sources

  1. wp_mail() WordPress Developer Resources
  2. phpmailer_init hook WordPress Developer Resources
  3. mail() PHP Manual
  4. Mail runtime configuration PHP Manual
  5. PHPMailer GitHub

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.