• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Configure WordPress on Ubuntu 22.04 to Send Emails

By Abhishek Ghosh January 29, 2024 5:58 pm Updated on January 29, 2024

Configure WordPress on Ubuntu 22.04 to Send Emails

Advertisement

To follow this guide, you need configure msmtp by following our previous guide. After following this guide, WordPress PHP and installation will be able to send you email.

 

Check Whether PHP Can Send Emails Using mSMTP

 

We need to test whether the php mail() function is working or not. Create a php script like the one below on your server, edit the required fields and save it as mail.php

Execute this script:

Advertisement

---

Vim
1
php mail.php

You should be able to receive an email. If you do not receive any email, check our guide How to Easily Set Up Email with SMTP on Ubuntu Server again and your email credentials. Also, check the log at /var/log/msmtp/msmtp.log.

Configure WordPress on Ubuntu 22-04 to Send Emails

 

Configure WordPress SMTP Settings to Send Emails Using mSMTP

 

I have created a small WordPress plugin for you with this content:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* Plugin Name: msmtp mail plugin
* Plugin URI: https://thecustomizewindows.com
* Description: Helps WordPress to send email using msmtp configuration on server
* Author: Abhishek_Ghosh
* Author URI: https://thecustomizewindows.com
* Version: 1.0
*/
 
/**
* This function will connect wp_mail to your authenticated mSMTP server.
*/
add_action( 'phpmailer_init', 'send_smtp_email' );
function send_smtp_email( $phpmailer ) {
        if ( ! is_object( $phpmailer ) ) {
                $phpmailer = (object) $phpmailer;
        }
 
        $phpmailer->Mailer     = 'smtp';
        $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;
}

You will get the plugin here on my GitHub repository. Simply copy this php file as a new file under /wp-content/plugins/ directory. Name the file as msmtp-mail-plugin.php.

Activate the plugin from WordPress Admin.

Open wp-config.php and add these constants before the line which says “That’s all, stop editing! Happy blogging”:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// add these before the line which says
/* That's all, stop editing! Happy blogging. */
 
// example with outlook
// edit SMTP_HOST, SMTP_USER, SMTP_PASS, SMTP_FROM, SMTP_NAME
define( 'SMTP_HOST',   'smtp.office365.com' );
define( 'SMTP_PORT',   '587' );
define( 'SMTP_SECURE', 'tls' );
define( 'SMTP_AUTH',    true );
define( 'SMTP_USER',   'username@hotmail.com' );
define( 'SMTP_PASS',   'your-password' );
define( 'SMTP_FROM',   'username@hotmail.com' );
define( 'SMTP_NAME',   'microsoft' );
 
/** Absolute path to the WordPress directory. */

Now your WordPress should be able to send email. Restart PHP-FPM. There is a WordPress plugin named Check & Log Email. This plugin will help you to send test email from WordPress.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Configure WordPress on Ubuntu 22.04 to Send Emails

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Easily Set Up Email with SMTP on Ubuntu Server

    It is very easy to use msmtp package, configure a dedicated email account for the server and send email alerts from the server or the web application, such as WordPress. However, for making web applications such as WordPress work, you need to perform a few extra steps which we have not described in this article. […]

  • Set Up Email with mSMTP on Ubuntu 22.04 Server

    This is a sendmail emulator system which delivers email from a local computer to an SMTP server. This method avoids the usage of cloud-based transactional email subscriptions. This is useful if you already using a paid tier of Outlook Gmail or Zoho for your domain. In other words, you’ll get domain-branded, whitelisted email from your […]

  • Configure WordPress to Send Emails Using mSMTP

    If you have followed our guide on How to Easily Set Up Email with SMTP on Ubuntu Server and want WordPress to send you email then you need to perform some extra steps. Make sure that you have completely followed our previous guide. Do not worry, this part is quite easy.   Check Whether PHP […]

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy