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

{% hint style="info" %}
**Please Note:** If you haven't already replaced the default "Email From Default" and "Email Reply Default" placeholder addresses, do that first — see [Setting Up Your Sender Email Addresses](/nats-admin/mass-mailing/common-question/setting-up-your-sender-email-addresses.md).
{% endhint %}

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

## 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.
{% 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).

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

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

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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2Fs7WTPEMvFFjZxswAMl1K%2Fnatsadmin-massmailing-settingupexternalmailservers-emailtab.png?alt=media&amp;token=d57438c4-2fa3-4775-8ff0-f1c5356abbc5" 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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FpvU9y7wOUCrA7tb8vkjk%2Fnatsadmin-massmailing-settingupexternalmailservers-emailfromdefault.png?alt=media&amp;token=f10a3142-d648-4a2e-b600-6875a48293cb" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2Fepgsnf1m6TBF6u0XKKGK%2Fnatsadmin-massmailing-settingupexternalmailservers-emailsendmethoddefault.png?alt=media&amp;token=af6559a1-6c7f-42a1-9fd1-0314f819ec34" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FyPNoNWwcPUMDkyPukKZh%2Fnatsadmin-massmailing-settingupexternalmailservers-smtpserverdefault.png?alt=media&amp;token=14c662c7-0d60-45c4-a991-39ba5e7d1d3a" alt=""><figcaption></figcaption></figure>

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

<div align="left"><figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FjbGlwhH8aG2lqiUtXrfD%2Fnatsadmin-massmailing-settingupexternalmailservers-username.png?alt=media&amp;token=40eabb96-90a0-4935-bca5-fde2b8519fef" alt=""><figcaption></figcaption></figure></div>

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

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FW3y1ZL8w6gArng8eMwDB%2Fnatsadmin-massmailing-settingupexternalmailservers-ssl.png?alt=media&amp;token=925e7ad9-b1fc-49a7-94fb-610a648a3112" 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.

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FWK43hotVTxJ8OPJ1BtxI%2Fnatsadmin-massmailing-settingupexternalmailservers-smtpportdefault.png?alt=media&amp;token=6ae8d4de-4f4d-46d7-bdc6-a4715ab5013d" 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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FN5DvpZ99h5677955i1jX%2Fnatsadmin-massmailing-settingupexternalmailservers-newmailer.png?alt=media&amp;token=0af55f1c-0c13-4b61-91a5-67ca663faa27" 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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2F0E2v0kQk9IbPaO7pBdj6%2Fnatsadmin-massmailing-settingupexternalmailservers-newmailersetup.png?alt=media&amp;token=a5402b1a-3652-4bd9-8d05-196a450bb6d8" alt=""><figcaption></figcaption></figure>

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

{% 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.
{% endhint %}

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2F1cs201m0nKRhx43bT3jM%2Fnatsadmin-massmailing-settingupexternalmailservers-sendtest.png?alt=media&amp;token=ab2b74e7-4865-4f3a-9273-8da41a79165b" 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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2F8qxRym0zaJXFX5S2eYkR%2Fnats-massmailing-sendtest-memberconfig.png?alt=media&amp;token=0ec462b7-a7df-4927-8fc6-05fcdeadb030" 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!

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

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.
