If you’re like most WordPress users, you’ve probably faced the frustrating issue of emails not being sent from your website.
Whether it’s order confirmations, contact form submissions, or any other type of communication, reliable email delivery is crucial.
The good news is, you don’t have to be a tech expert to solve this problem.
In this guide, I’ll walk you through three effective methods to ensure your WordPress emails are sent and received as intended.
Method 1: Using the wp_mail() Function
The wp_mail() function is WordPress’s built-in way to send emails. It’s simple and doesn’t require any additional setup, making it a go-to option for many users.
However, it’s important to understand that this method relies on your web host’s mail server, which can lead to emails being marked as spam or not delivered at all.
Steps to Use wp_mail():
- Prepare Your Email:
Thewp_mail()function allows you to specify the recipient, subject, message, and even attachments. Here’s a basic example of how to use it:
wp_mail( '[email protected]', 'Your Subject Here', 'Your message content here.' );
- Add the Code to Your Theme or Plugin:
You can place the above code in your theme’sfunctions.phpfile or within a custom plugin. This ensures that the email function is triggered when needed, such as when a form is submitted. - Test the Functionality:
After saving your changes, test the function by triggering an email, for instance, by submitting a contact form. Be sure to check both the inbox and spam folder to see if the email was delivered correctly.
Why You Might Experience Issues:
The biggest drawback of using wp_mail() is its reliance on your server’s email configuration.
Many shared hosting providers don’t have optimized mail servers, leading to poor deliverability.
If you find that emails are landing in spam or not being sent at all, you might want to consider the next method.
Method 2: Using an SMTP Plugin
If you’re looking for a more reliable way to send emails from WordPress, using an SMTP (Simple Mail Transfer Protocol) plugin is highly recommended.
One of the most popular plugins for this purpose is WP Mail SMTP by WPForms.
Steps to Use an SMTP Plugin:
Install the Plugin:
- Log in to your WordPress admin dashboard.
- Navigate to Plugins > Add New.
- Search for WP Mail SMTP by WPForms.
- Click Install Now, then Activate.
Configure the Plugin:
- Go to WP Mail SMTP in your dashboard menu.
- Under the General tab, set your From Email (e.g., [email protected]) and From Name (e.g., Your Website Name).
- In the Mailer section, choose your SMTP service (e.g., Other SMTP for custom settings).
Enter Your SMTP Settings:
- Fill in the details provided by your email service provider:
- SMTP Host: For example,
smtp.gmail.comif you’re using Gmail. - SMTP Port: Use
465for SSL or587for TLS encryption. - Encryption: Choose between SSL or TLS based on your provider’s recommendation.
- SMTP Username: Your full email address.
- SMTP Password: The password for your email account.
- SMTP Host: For example,
Send a Test Email:
- Go to the Email Test tab within the plugin settings.
- Enter a valid email address and click Send Email.
- Check the inbox of the recipient email to confirm successful delivery.
Benefits of Using an SMTP Plugin:
Using an SMTP plugin like WP Mail SMTP greatly improves email deliverability.
Unlike the wp_mail() function, which relies on your hosting server, SMTP sends emails through a designated email provider, reducing the chances of emails being flagged as spam.
Other great alternatives include Post SMTP and FluentSMTP, which also offer robust features for reliable email sending.
Method 3: Manually Configuring SMTP
For those who prefer a hands-on approach and don’t mind getting into the technical details, manually configuring SMTP settings is another option.
This method involves adding your SMTP credentials directly to your WordPress files, giving you more control over your email configuration.
Steps to Manually Configure SMTP:
- Edit Your
wp-config.phporfunctions.phpFile:
- Open your site’s
wp-config.phporfunctions.phpfile via FTP or your hosting control panel. - Add the following code, replacing the placeholder values with your actual SMTP credentials:
add_action( 'phpmailer_init', 'my_phpmailer_smtp' );
function my_phpmailer_smtp( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.yourhost.com'; // Your SMTP server
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465; // Use 587 for TLS
$phpmailer->Username = '[email protected]';
$phpmailer->Password = 'your_password';
$phpmailer->SMTPSecure = 'ssl'; // Use 'tls' for TLS
$phpmailer->From = '[email protected]';
$phpmailer->FromName = 'Your Name';
}- Send an Email:
- Use the
wp_mail()function, as described in Method 1, to send emails through your manually configured SMTP setup.
Advantages and Considerations
Manually configuring SMTP gives you more flexibility and control over how emails are sent from your WordPress site.
However, this method is more complex and requires a good understanding of PHP and WordPress file structure.
If done incorrectly, it can cause issues with your site, so proceed with caution or consider using an SMTP plugin if you’re not confident with code.
Conclusion
Getting emails to send reliably from WordPress doesn’t have to be a headache.
Whether you choose to use the wp_mail() function, an SMTP plugin, or manually configure your SMTP settings, each method offers a solution to fit different needs and technical skill levels.
Personally, I find that using an SMTP plugin strikes the best balance between ease of use and reliable email delivery.
Which method do you think you’ll try first? I’d love to hear your thoughts in the comments below.
And don’t forget to explore our other blog articles related to WordPress to keep improving your website’s performance!



