• 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 to Send Emails Using mSMTP

By Abhishek Ghosh May 29, 2023 5:24 pm Updated on May 29, 2023

Configure WordPress to Send Emails Using mSMTP

Advertisement

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 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 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
// add these before the line which says
/* That's all, stop editing! Happy blogging. */
 
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. */

Edit it with real value. This is a working example with our website’s setup:

Configure WordPress to Send Emails Using mSMTP

Now your WordPress will be able to send email.

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 to Send Emails Using mSMTP

  • 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. […]

  • Join/Merge Multiple Log Files For Big Data Analysis

    Here Are The Ways To Join/Merge Multiple Log Files For Big Data Analysis, Store Them To OpenStack Based Cloud Storage And Delete Old Files.

  • 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.

  • How to Understand the Reputation of SMTP Server to Send emails

    How to Understand the Reputation of SMTP Server to Send emails, because the ability to receive an email or newsletters by users is dependent on the reputation.

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…

 

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

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

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

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