How to Fix WordPress Not Sending Emails Without a Plugin (Using SMTP + Code Only)

Fix WordPress Not Sending Emails Without a Plugin (Using SMTP + Code Only)

Introduction

WordPress not sending emails without plugin? You’re not alone — this is a common issue that frustrates a ton of site owners, but there’s a clean fix.

This is a common problem, often due to the default PHP mail function lacking proper authentication, leading to emails being marked as spam or not delivered at all. While plugins like WP Mail SMTP can resolve this, they add extra overhead. In this guide, we’ll walk you through configuring SMTP manually using code, enhancing email deliverability without relying on plugins.

Why WordPress Emails Fail to Send

This issue is especially common if you’re trying to fix WordPress not sending emails without plugin, as the default PHP mail function lacks proper authentication.

  • PHP Mail Function Limitations: WordPress uses the wp_mail() function, which relies on PHP’s mail() function. This method doesn’t support authentication, making emails susceptible to being flagged as spam.
  • Hosting Server Restrictions: Some hosting providers disable the PHP mail() function to prevent abuse, leading to email del
  • Lack of Authentication Protocols: Without proper authentication protocols like SPF, DKIM, and DMARC, emails are more likely to be rejected by recipient servers.

Benefits of Using SMTP

If you’re attempting to solve WordPress email issues without using a plugin, SMTP is the most reliable approach.

  • Improved Deliverability: SMTP uses proper authentication, ensuring emails are recognized as legitimate by recipient servers.
  • Enhanced Security: SMTP supports encryption protocols like SSL/TLS, securing email content during transmission.
  • Better Control: Manual configuration allows for greater control over email settings, reducing reliance on third-party plugins.

How to Fix WordPress Not Sending Emails Without a Plugin (Step-by-Step)

1. Gather SMTP Credentials

Before proceeding, obtain the following details from your email service provider:

  • SMTP Host (e.g., smtp.gmail.com)
  • SMTP Port (e.g., 587 for TLS or 465 for SSL)
  • SMTP Username (your email address)
  • SMTP Password
  • Encryption Type (tls or ssl)

2. Define SMTP Settings in wp-config.php

Add the following lines to your wp-config.php file, just before the line that says 

/* That's all, stop editing! Happy publishing. */:

define( 'SMTP_USER',   'your_email@example.com' );
define( 'SMTP_PASS',   'your_email_password' );
define( 'SMTP_HOST',   'smtp.example.com' );
define( 'SMTP_FROM',   'your_email@example.com' );
define( 'SMTP_NAME',   'Your Name or Website' );
define( 'SMTP_PORT',   '587' ); // Use 465 for SSL
define( 'SMTP_SECURE', 'tls' ); // Use 'ssl' if applicable
define( 'SMTP_AUTH',   true );
define( 'SMTP_DEBUG',  0 );

Note: Replace the placeholder values with your actual SMTP credentials.

3. Configure PHPMailer in functions.php

In your theme’s functions.php file (preferably in a child theme to prevent overwriting changes during updates), add the following code:

add_action( 'phpmailer_init', 'configure_smtp' );
function configure_smtp( $phpmailer ) {
    $phpmailer->isSMTP();
    $phpmailer->Host       = SMTP_HOST;
    $phpmailer->SMTPAuth   = SMTP_AUTH;
    $phpmailer->Port       = SMTP_PORT;
    $phpmailer->Username   = SMTP_USER;
    $phpmailer->Password   = SMTP_PASS;
    $phpmailer->SMTPSecure = SMTP_SECURE;
    $phpmailer->From       = SMTP_FROM;
    $phpmailer->FromName   = SMTP_NAME;
}

This code tells WordPress to use SMTP for sending emails, utilizing the credentials defined in wp-config.php.

Testing the Configuration

To ensure everything is set up correctly, you can send a test email using the following code snippet:

wp_mail( 'recipient@example.com', 'Test Email', 
'This is a test email sent from WordPress using SMTP.' );

Replace recipient@example.com with your actual email address. You can add this code temporarily to a template file or use a custom plugin to execute it.

💬 Need help setting this up? Contact me here

Troubleshooting Tips

  • Enable Debugging: Set define( 'SMTP_DEBUG', 1 ); in wp-config.php to enable debugging and view detailed error messages.
  • Check Firewall Settings: Ensure your hosting server’s firewall allows outbound connections on the SMTP port you’re using.
  • Verify Credentials: Double-check your SMTP username and password for accuracy.
  • Use App Passwords: If using services like Gmail with two-factor authentication, generate an app-specific password for SMTP.

Conclusion

If you’ve been struggling with WordPress not sending emails without a plugin, this approach gives you the control and performance you’re looking for.

By configuring SMTP manually, you enhance your WordPress site’s email reliability without adding extra plugins. This approach provides better control, security, and performance. Always ensure you handle your SMTP credentials securely and consider using environment variables or secure storage methods for added safety.

If your site is also showing a blank screen, check out our step-by-step guide on fixing the WordPress white screen of death — a common issue when plugin or theme conflicts occur. And if you recently changed your theme and things look broken, here’s how to fix broken layouts after switching WordPress themes without losing your design or user experience.

Frequently Asked Questions

Most WordPress sites fail to send emails due to hosting restrictions, lack of SMTP authentication, or misconfigured wp_mail() settings.

Yes, you can configure SMTP manually using code in functions.php and wp-config.php to send emails without using any plugin.

The safest way is to manually set up SMTP using your provider’s credentials and hook into phpmailer_init to securely send emails.

You should store SMTP credentials in your wp-config.php file to keep them out of your theme files and improve security.

If you don’t use SMTP, emails may go to spam due to missing authentication (SPF, DKIM). Proper SMTP setup fixes this regardless of plugin use.

Use port 587 for TLS or 465 for SSL. Make sure your host allows outbound SMTP connections on these ports.

Not by default. WordPress uses wp_mail() which wraps around PHP’s mail() function unless SMTP is configured via code.

Yes, but you’ll need to enable App Passwords in your Google Account and configure those credentials in your site’s wp-config.php.

You might miss important contact form submissions, order confirmations, or admin notifications—impacting user experience and reliability.

For developers or performance-focused users, manual SMTP setup reduces plugin bloat and gives full control over mail delivery settings.

Leave a Reply

Your email address will not be published. Required fields are marked *

    Branding Design Development Front-End Website-Redesigning Shopify-Development WordPress-Development
    Branding Design Development Front-End Website-Redesigning Shopify-Development WordPress-Development
    We love crafting unforgettable
    digital experiences, brands and websites with people like you.
    Follow us:
    Let’s get started
    We'd love to hear about your project.
    © 2025 babarilyas. All rights reserved.