> For the complete documentation index, see [llms.txt](https://docs.toomuchmedia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toomuchmedia.com/nats-admin/mass-mailing/common-question/setting-up-an-external-mail-server-smtp-gmail.md).

# Setting Up an External Mail Server (SMTP/Gmail)

*Article Topics:* [*Emails*](/getting-started/common-topics/emails.md)*,* [*Customization*](/getting-started/common-topics/customization.md)*,* [*Members*](/getting-started/common-topics/members.md)*,* [*Affiliates*](/getting-started/common-topics/affiliates.md)

## Setting Up an SMTP Server in NATS

Using NATS, you can send out mail from an external mail server. A list of General Settings for setting up your email can be viewed in the following article: [Configuration Emails](/nats-admin/configuration/configuration-overview/emails.md).

This article will provide you with a step-by-step guide on setting up an external mail server in NATS.  &#x20;

## Using Gmail Workspace

{% hint style="info" %}
**Please Note:** In this example, we will be using Gmail but the process is similar regardless of email domain provider.&#x20;
{% endhint %}

Before setting up in NATS, you must set up your own SMTP server. The following article provided by google is a perfect resource for setting up your Google SMTP settings: [Send email with the Gmail SMTP server](https://support.google.com/a/answer/176600?hl=en#:~:text=Option%202%3A-,Send%20email%20with%20the%20Gmail%20SMTP%20server,-If%20you%20connect).

Once this is complete, you will be given the following information:

* Gmail SMTP server name
* Gmail SMTP username&#x20;
* Gmail SMTP password
* SMTP Port Number using the following numbers depending on the settings
  * **465** for **SSL**&#x20;
  * **587** for **TLS**&#x20;

To learn more about Google Workspace email aliases, please see the following [About Google Workspace Email Aliases](https://support.google.com/domains/answer/6304345?hl=en) article.

## NATS Configuration

To configure NATS with your external mail server, obtain the necessary details from your mail server and insert this information into the NATS configuration with the following steps:

1\) Navigate to the Configuration Admin and select the [Emails ](/nats-admin/configuration/configuration-overview/emails.md)tab.

<figure><img src="/files/s4zvSFCdk8uc1YAdMMTo" alt=""><figcaption></figcaption></figure>

2\) Set the "Email From Default" and "Email Reply Default" settings to your Gmail workspace email address.

{% hint style="info" %}
**Please Note:** You can additionally set the nice name for both "Email Reply" and "Email From" in the respective "Email From Nice Default" and "Email Reply Nice Default" settings.
{% endhint %}

<figure><img src="/files/isUtslGZ7Y7JI9QiL9pv" alt=""><figcaption></figcaption></figure>

3\) Set the "Email Send Method Default" setting to Custom SMTP.

<figure><img src="/files/NxlHEHejWi0aCT0B3HiA" alt=""><figcaption></figcaption></figure>

4\) Set the "Email SMTP Server Default" setting to the Gmail SMTP Server hostname, smtp.gmail.com.

<figure><img src="/files/WWPBOtIhD7A2JzQe9nHK" alt=""><figcaption></figcaption></figure>

5\) Set the Email SMTP Username and the Email SMTP Password to your mail server username and password.&#x20;

<div align="left"><figure><img src="/files/OkM4Iehcb5qPLd8tN5Ua" alt=""><figcaption></figcaption></figure></div>

6\) Set the Email SMTP Secure Default to SSL or TLS depending on your Gmail workspace settings.&#x20;

<figure><img src="/files/6t3cNswZ3X9jAg5kwYoW" alt=""><figcaption></figcaption></figure>

7\) Set the Email SMTP Port Default to 465 for SSL or 587 for TLS depending on your "Email SMTP Secure Default" setting.&#x20;

<figure><img src="/files/dHJZnL5bq9IOGESAGLzF" alt=""><figcaption></figcaption></figure>

## Testing the External Email

Once you have configured these settings, navigate to the Mass Mailing admin and create a new Mailer by clicking the "Add New Mailing."

<figure><img src="/files/LoFJuHayXGVUYzvewWDl" alt=""><figcaption></figcaption></figure>

Set the subject and mail target, as well as the "Send On" setting, ensuring it is set to "Never."

<figure><img src="/files/4LgYOnrRmslIF548tmJo" alt=""><figcaption></figcaption></figure>

Edit the message body and select the "Send Test" button at the top of the page to send your test.&#x20;

{% hint style="info" %}
**Please Note:** This test email will be sent to the email address tied to the admin account you are currently logged into.&#x20;
{% endhint %}

<figure><img src="/files/UxaXEIOAdl0LCI3WBhpN" alt=""><figcaption></figcaption></figure>

If the Mail Target is set to Members, ensure that an example member that meets the [Rule](/using-nats/nats-admin-features/rules.md) conditions of the test email is set in the "Test Member Mailing" setting in the [Email section ](/nats-admin/configuration/configuration-overview/emails.md)of the Configuration Admin.

<figure><img src="/files/13YpZUVRGmyeIoYnBROI" alt=""><figcaption></figcaption></figure>

To verify your test, go back to Gmail and see if you have received the test message. Once you have verified that the email has been sent, you are all set!&#x20;

## Troubleshooting

If your Google SMTP credentials are correct when you attempt to log in via the web, but emails fail to send, this could be due to a Google Workspace default settings where "less secure apps" is disabled.&#x20;

The following is an error message that has been manually logged:

```
SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. 
Learn more at https://support.google.com/mail/?p=BadCredentials.
```

To resolve this issue,  you will need to enable "Less Secure Apps." You can do this by following the method provided by google on the [Control Access to less secure apps](https://support.google.com/a/answer/6260879?hl=en), [How to enable less secure application access](https://knowledge.workspace.google.com/kb/how-to-enable-less-secure-application-access-000006971), and [Allow less secure apps for individual accounts](https://support.google.com/accounts/answer/6010255?hl=en#zippy=%2Cif-less-secure-app-access-is-on-for-your-account%2Cif-less-secure-app-access-is-off-for-your-account) articles.&#x20;
