Configure your WordPress site to send E-mail via SMTP mail server | GoDaddy and Office 365 based environment | Part 1#6 5/5 (1) 18 min read

In the current article series, we review the steps by step instructions,
that are needed for configuring WordPress site to send E-mail by using an SMTP mail server.

Generally speaking, the required configuration that is needed depends on three variables:

  1. The network infrastructure which hosts the WordPress site
  2. The specific characters of the mail server that we address
  3. The WordPress site plugin or PHP code that we use

The scenarios that we will review are:

1. A WordPress site that has SMTP\TLS access to external Office 365 mail servers.

In the article – Configure your WordPress site to send E-mail via Exchange Online (Office 365) anonymous session | Part 2#6, we review the required settings, in a scenario in which we want to configure our WordPress site to address the Office 365 mail server using SMTP protocol without authentication (Anonymously, without providing user credentials).

The outcome of this configuration will lead to a scenario in which the E-mail that will be sent to our organization users will be classified as “spam mail.
In the article – Creating Exchange Online bypass spam rule – whitelist specific sender E-mail address | Part 3#6, we will learn how to avoid this “outcome,” by creating a rule that will “whitelist” the sender E-mail address.

In the article – Configure your WordPress site to send E-mail via Exchange Online (Office 365) provide user credentials | Part 4#6 , we review the required settings, in a scenario in which we want to configure our WordPress site, to address the Office 365 mail servers using TLS protocol + providing user credentials.

In the article – Configure WordPress site send E-mail via Exchange Online (Office 365) | Provide user credentials without purchase Office 365 license | Part 5#6, we review a method which we can use for saving the cost of purchase Office 365 license to the user that our WordPress site for the authentication purpose.

2.  WordPress site that hosted at GoDaddy using Shared Hosting

In the article – Configure your WordPress site to send E-mail via GoDaddy mail server – Shared Hosting plan | Part 6#6 , we review the required settings in a scenario, in which we want to configure our WordPress site that uses Shared Hosting plan, to address the GoDaddy mail server.

Why is it so hard to configure my WordPress site to use mail server?

The task of successfully manage to configure our WordPress site to address mail server puts before us a number of challenges ahead.

The obstacles we went through in order to set our WordPress site to use mail server

The main challenge is – our need, to be familiar with the specific requirement of the mail infrastructure that we need to address, and the structure of the network, that hosts our WordPress site.

Apparently, the configuration of WordPress, setting look quite simple because we use a graphic interface, but the “catch” is that in many scenarios, we don’t really know what are the required configuration settings that are required by the destination mail infrastructure.

In the following diagram, we can see an example of the different “mail components” that we need to know about the mail server which we want to address.

WordPress and mail server -What are the details that we need to know about the mail server

A1. Mail communication protocol

The default communication protocol that we usually use – is the SMTP protocol. The SMTP protocol is a non-encrypted protocol. In some scenario, we would prefer to use the TLS mail protocol because the TLS protocol encrypts to the communication channel between the two endpoints.

In case that we want to use (or need to use) the TLS mail protocol there are additional elements that we should relate to such as

A1.1 – The TLS version that supported by the mail client and the mail server.

For example, in a scenario in which we want to configure our WordPress site to address Exchange Online as mail server using TLS, the supported TLS version is TLS 1.0 and above.

From my own experience, many WordPress plugins don’t support the required TLS version or have other problems when trying to address Exchange Online using TLS.

A1.2 – The TLS mandatory requirement of the mail server

The TLS protocol can be configured using advanced configuration, such as the requirements of using the certificate, the requirement in which the certificate should include a specific hostname and more. These requirements could be considered as optional or mandatory requirements.

For example, in a scenario in which we want to configure our WordPress site to address Exchange Online as mail server using TLS, the Exchange Online doesn’t enforce a mandatory requirement in which the side that communicates the mail server will need to use a certificate.

In other words, in a scenario in which we need to address Exchange Online using TLS, we don’t need to use a “client side” certificate.

A2. Mail communication protocol port number

  • The default SMTP communication port number is – 25
  • The default TLS communication port number is – 587

We will need to verify that we know what is the port number that is used by the mail server that we need to address.

For example

  • When we need to configure our WordPress site to address Exchange Online as mail server using SMTP, the communication port number that we need to configure is – 25.
  • When we need to configure our WordPress site to address Exchange Online as mail server using TLS, the communication port number that we need to configure is – 25 or 587. Exchange Online support TLS communication using port 25 and in addition port 587.

Mail communication protocol port number and Firewall infrastructure

A very important issue to consider that relates to the communication protocol port number is – the existing outbound Firewall policy.

For example, in many scenarios, the reason for the “mail communication failure” is related to the fact that the existing Firewall infrastructure that “protect” our WordPress site, doesn’t allow our web server to communicate with external hosts using SMTP (port 25) or TLS (port 587) protocols.

We will need to verify that the existing network in which we host our WordPress site, allow this type of outbound mail communication.

In the article -Configure your WordPress site to send E-mail via Exchange Online (Office 365) using TLS | Part 4#6, we will review how to verify the outbound communication with the destination mail server using a special feature of the Postman SMTP Mailer/Email Log mail plugin.

B. Mail communication and Authentication

The communication channel between the mail client the (WordPress site in our scenario) and the mail server, can be implemented as a “none- authenticated” session or “authenticated session”.

The mail server can “dictate” a mandatory requirement, in which he is willing to accept the mail client requests only if the mail client proof his identity by providing user credentials. Another scenario could be – a scenario in which the mail server is willing to accept anonymous mail delivery request.

Example 1 – in a scenario in which we want to configure Exchange Online as a mail server, we can address the Exchange Online mail server without providing user credentials or with user credentials (later on we will explain why the preferred option is – provide user credentials).

Example 2 – in a scenario in which the WordPress site is hosted at GoDaddy using Shared Hosting plan, we don’t need to provide user credentials

The other element that relates to the subject of – authenticated session is the authentication protocol that is required by the mail server.

For example, when we address Exchange Online as a mail server, and we want to provide user credentials, Exchange Online will “agree” to accept the user credentials only if we configure the session using the TLS protocol.

C. The address of the mail server, which we need to address

Although these “requirement” looks like an obvious requirement, in reality, you will find that is not so “clear”.

Addressing Office 365 mail servers | WordPress site

In case that we want to address Office 365 mail infrastructure, we can address the “Office 365 mail server” using one of the following “entities”:

1.  The Office 365 mail server – SMTP entity

In case we configure the WordPress mail plug-in to connect Exchange Online using SMTP, the host name whom we need to use is – the hostname who appears as the “Office 365 MX record.”

In case that you need more information, you can read the article – What is the hostname of my Office 365 MX records?

I will demonstrate this configuration in the article in the section – Configure your WordPress site to send E-mail via Exchange Online (Office 365) anonymous session | Part 2#6

2.  The Office 365 mail server – TLS entity

In case we configure the WordPress mail plug-in to connect Exchange Online using authenticated session + using TLS protocol, the host name whom we need to use
is –  smtp.office365.com
Addressing GoDaddy mail server -Shared Hosting plan | WordPress site

The characters of this scenario are WordPress site that is hosted at some Web hosting providers such as GoDaddy.

In this type of scenario, the common network infrastructure is implemented by a mail server that the web hosting provider “expose” to the use of his customers.

For customers who use GoDaddy Shared Hosting plan, the mail server that provides by GoDaddy named – relay-hosting.secureserver.net

I will demonstrate this configuration in the article – Configure your WordPress site to send E-mail via GoDaddy mail server – Shared Hosting plan | Part 6#6

Implementing an authenticated mail session in an Office 365 based environment

Generally speaking, the preferred communication channel between the mail client (the WordPress site in our scenario), and the mail server should be implemented as “authenticated session.”

In other words, the mail client needs to provide user credentials before starting The SMTP session with the mail server.

In case that the mail client provides his credentials, the mail server can “trust” the mail client, and trust the mail client requests for delivering E-mail to organization recipient or external mail recipients.

There are two main advantages for a scenario in which we configure the mail client to provide user credentials:

1.  E-mail address that sent to an organization recipient is not classified as spam mail

To be able to understand better the above sentence, let’s use the following scenario:

  • Our domain name is – o365info.com
  • We want to configure our WordPress site, to use our organization’s mail server (the mail server that represents the domain name – com).
  • Our WordPress site is configured to send E-mail using the E-mail address –support@o365info.com
  • The WordPress site sends E-mail to a destination recipient – Bobm@o365info.com

Option 1 – In case that the mail client (WordPress site), was configured to provide user credentials, the E-mail that was sent will be considered as a “legitimate E-mail” because the organization sender (support@o365info.com) can prove his identity.

Option 2 – In case that the mail client (WordPress site), was configured to not to provide user credentials (anonymous connection), the E-mail that was sent will be considered as a “non-legitimate E-mail” because, the sender (support@o365info.com) “claim” that he is a legitimate organization sender, but he cannot prove his identity. In this case, the outcome could be that the E-mail will be rejected by the o365info mail server or “stamped” as a spam mail.

2.  The ability to send E-mail to the external recipient

When we address our mail server and ask him to “deliver” E-mail to an external recipient, (recipient whom his E-mail address includes a domain name that is not hosted by our mail server) from the mail server point of view, the recourse for delivering the E-mail
considers as a “relay.”

By default, most of the mail servers are configured to “agree” to relay mail delivery requests, only if the mail client considers as “trusted mail client.” In other words, only if the mail client can prove his identity by providing legitimate user credentials.

In a scenario in which we need to send E-mail to “external recipient,” and we don’t provide user credentials to the mail server; the mail delivery request will be rejected!

WordPress site address Exchange Online as mail server - Authenticated session

And now, let’s ask an obvious question that can appear in your mind:

Q1: If you say that the method in which we provide user credentials have all of the above advantages, why don’t we just provide the required credentials instead of philosophizing this subject?

A1: A common scenario, is a scenario in which we define the “identity” (E-mail address) of the WordPress site, to use a “service E-mail” such as – support@o365info.com, that will serve as a “logical entity” and in reality, there is no such user account.

To be able to implement the “best practice” configuration and provide the required user credentials, we will need to have the credentials of a “legitimate Office 365 users” with a license.

Many times, we would prefer to avoid from purchasing the Office 365 licenses
for the WordPress “service account.”

In this case, we can define the communication with the Exchange Online mail server as “anonymous session,” without providing credentials, but this method has cons versus the authenticated session.

Office 365 user with mailbox need a license

Q2: In case that we want to enjoy the benefits of using authenticated session, does it mean that we have to purchase a dedicated Office 365 user license?

A2: Generally speaking, the answer is “yes.” The good news is that we can use a little trick that will enable us to use an existing Office 365 user credentials, and configure the WordPress site to use a different E-mail address from the original E-mail address of the Office 365 user.

For example, in case that we have Office 365 users named Bob that has an Exchange Online mailbox (Office 365 license) we can use Bob’s credentials and provide the “logic E-mail address” such a support@o365info.com

We will review how to implement this option in the article – Configure WordPress site send E-mail via Exchange Online (Office 365) | Provide user credentials without purchase Office 365 license | Part 5#6

A scenario in which our WordPress site supports only SMTP

In case that we cannot provide Office 365 user credentials or in case that from some reason, the WordPress mail plugin that we use doesn’t support the required TLS protocol version, we can configure a “standard SMTP session” without providing any user credentials.

As mentioned, this method has drawbacks versus the “authenticated configuration”

We will review how to create the required configuration in Exchange Online in the  article – Configure your WordPress site to send E-mail via Exchange Online (Office 365) anonymous session | Part 2#6

WordPress and mail server | Additional challenges

In this section, I would like to review an additional challenge, that we will need to face in our journey of configuring our WordPress mail plug-in to connect mail server.

1.  How to troubleshoot or debug mail communication failure?

In a scenario in which we configure all the necessary configurations in our WordPress mail
Plug-in, and still don’t manage to successfully send E-mail to the required destination recipient, the main troubleshooting challenge is – how to locate the specific cause of the problem?

Q: Does the reason for our mail communication failure, relate to the Firewall to protect our network and maybe block SMTP communication?

Q: Does the reason for our mail communication failure, relate to user credentials that we use or the credentials that we didn’t provide?

Q: Does the reason for our mail communication failure, relate to the TLS protocol settings?

In the real-life scenario, there could be many optional causes for the mail communication failure. The ability to locate the problem become more difficult because, many of the WordPress mail plug-ins, are very limited in their ability to provide detailed information about the mail session or. Provide tools and log files that can help us to understand better the real cause of the problem.

2.  What WordPress plugin to use?

If you perform a simple search looking for – WordPress mail plug-in, you will find plenty of such plug-ins.

I try some of the “recommended” or “Popular” WordPress mail plug-ins, and finally select the following WordPress mail plug-in – Postman SMTP Mailer/Email Log.

I have selected the Postman SMTP Mailer/Email Log because he has a very friendly user interface, and he includes very powerful and useful built troubleshooting tools, that can help us to troubleshoot mail flow failure scenarios.

I want to emphasize the fact that I am “neutral” and I have no special relationship with the creator of the Postman SMTP Mailer/Email Log WordPress mail plug-in. I’m sure that there are more useful and “easy to use” WordPress mail plug-ins.

3.  Requirement of configurations in Exchange Online, to prevent scenarios in which the
E-mail will be classified as spam mail

As mentioned before, in a scenario in which configure the WordPress mail plug-in to address Exchange Online server without providing user credentials, the main disadvantage is that the E-mail that is sent from the WordPress site will probably classify as spam mail.

To be able to prevent this scenario, we will need to add some configurations on the Exchange Online server side, that will “inform” the Exchange Online server that E-mail that is sent by our WordPress website is a legitimate E-mail.

We will review this configuration in the article – Creating Exchange Online bypass spam rule – whitelist specific sender E-mail address | Part 3#6

WordPress and mail server - Additional challenges

Configure WordPress site to address mail server | Three common mail flow scenarios

In the following section, I would like to review the most common mail flow scenarios that implemented when we want to configure our WordPress site to address mail server.

The information about the specific characters of each scenario will help us to understand better what is the specific scenario which is related to our specific environment.

For example, our WordPress site could be installed (hosted) on the organization server who’s located in our local organization’s network. Another scenario could be a scenario in which our WordPress site is hosted at the external provider such as GoDaddy.

In a scenario in which our WordPress site is hosted by external providers, we will need to verify if this provider provides us an access to the mail server which we can address or in a scenario in which we want to address “external mail server” such as Exchange Online, does the provider enable us to create an outbound session using port 25 or 587.

Scenario 1 – WordPress website using the local SMTP server

In this scenario, the server who hosts the WordPress site, host, in addition, an “SMTP mail server.”

To be able to send E-mail to recipients, we will configure the WordPress mail plug-in, to address the hostname or the IP address of the local SMTP server.

Needed less to say that we will need to get the local IP address of the host name of the local SMTP server from the “person” that manage the specific server.

Scenario 1 – WordPress web site using local SMTP server

Scenario 2 – WordPress website and shared hosting using the External SMTP server

In this scenario, the “SMTP mail server” is installed on another machine. An example could be -web hosting provider such as GoDaddy.

GoDaddy customers who shared hosting web hosting service, that needs the services of “SMTP mail server” can address the GoDaddy mail server that is represented by the host name – relay-hosting.secureserver.net

Scenario 2 – WordPress web site using External SMTP server

Scenario 3 – WordPress website using Exchange Online as External SMTP server

In this scenario, the “SMTP mail server” that we want to address is – the Office 365 mail servers (Exchange Online).

This scenario is relevant for Office 365 customers, that want to use the Office 365 mail services as the “mail server” that will be used by the WordPress site.

Just a quick reminder regarding the specific characters of Office 365 mail services:

We can address Office 365 mail servers by using SMTP or TLS protocol.

  • In case that we address Office 365 mail servers by using SMTP, we cannot provide user credentials, and the connection will be considered as “anonymous connection.” In this scenario, at a later stage, we will need to configure a specific Exchange Online setting that will not classify the E-mail that is sent from the WordPress site as spam (because of the anonymous connection).
  • In case that we address Office 365 mail servers by using authenticated session and TLS protocol, we will have to address the Exchange Online server by using the host name – office365.com.

Scenario 3 – WordPress web site using Exchange Online as External SMTP server

Comparison table – addressing Office 365 mail servers anonymously versus authenticated session

The following table, serve as a comparison table between the two optional methods that we can use in a scenario in which we want to configure our WordPress site to use Office 365 mail services:

Comparison table – addressing Office 365 mail servers anonymously versus authenticated session

Configure your WordPress site to send E-mail via Office 365 or SMTP mail server| Article series index

Now it’s Your Turn!
It is important for us to know your opinion on this article

Print Friendly

Related Post

Please rate this

Eyal Doron on EmailEyal Doron on FacebookEyal Doron on GoogleEyal Doron on LinkedinEyal Doron on PinterestEyal Doron on RssEyal Doron on TwitterEyal Doron on WordpressEyal Doron on Youtube
Eyal Doron
Share your knowledge.
It’s a way to achieve immortality.
Dalai Lama

Leave a Reply

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