> For the complete documentation index, see [llms.txt](https://docs.emaillabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emaillabs.io/en/integrations/smtp/smtp-relay.md).

# SMTP Relay

## Configuring a Local SMTP Relay with EmailLabs <a href="#docs-internal-guid-642c3b62-7fff-04a9-3299-7c1fc6d78d53" id="docs-internal-guid-642c3b62-7fff-04a9-3299-7c1fc6d78d53"></a>

Setting up a local mail server as an SMTP relay to EmailLabs enables more stable and efficient email sending. The queuing mechanism enhances the reliability of the sending process, and in case of connection issues, messages will be automatically resent.

By utilizing the SMTP protocol with "pipelining" and connection caching features, it's possible to significantly increase performance, especially when sending a large number of messages.

### Finding SMTP data in EmailLabs

The data needed for integration via SMTP can be found in the EmailLabs panel in the section: **Email API -> Settings -> SMTP Accounts**.

<figure><img src="/files/7LwJD9r04iwj1GYPQVZs" alt=""><figcaption></figcaption></figure>

### SMTP Relay Configuration

{% tabs %}
{% tab title="Postfix" %}
To correctly configure the Postfix server, log in as root or obtain root privileges using the **su** or **sudo** command. Then, in the configuration file **/etc/postfix/main.cf**, add the following entry:

```
relayhost = [smtp.emaillabs.net.pl]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options = 
```

Next, you need to create a password file at the path mentioned in the previous entry:

```
cd /etc/postfix/ touch relay_password
```

In the created file, add:

```
smtp.emaillabs.net.pl user_name:password
```

Save the file and for security, change the file permissions using the command:

```
postmap /etc/postfix/relay_password
chmod 600 /etc/postfix/relay_password /etc/postfix/relay_password.db
```

{% hint style="info" %}
If you don't have the libsasl2 (SASL) library installed, make sure to install it before restarting Postfix.
{% endhint %}

Finally, you should restart the Postfix server.

```
/etc/init.d/postfix restart
```

{% endtab %}

{% tab title="Sendmail" %}
To configure Sendmail as a mail relay, log in as root, or obtain root privileges using the **su** or **sudo** command. Then, add the following line to the file **/etc/mail/access**:

```
AuthInfo:smtp.emaillabs.net.pl "U:user_name" "P:password "M:PLAIN"
```

In the next step, you should configure the Smart Host in the **/etc/mail/sendmail.mc** file. Under the line starting with #dnl define... add:

```
define(SMART_HOST', smtp.emaillabs.net.pl')dnl
FEATURE(`access_db')dnl
define(RELAY_MAILER_ARGS', TCP $h 587')dnl
define(ESMTP_MAILER_ARGS', TCP $h 587')dnl
```

Then, you need to update the entered data. Navigate to the /etc/mail/ folder and execute the following commands:

```
m4 sendmail.mc >sendmail.cf
makemap hash access < access
```

Remember to restart the Sendmail server:

```
/etc/init.d/sendmail restart
```

{% endtab %}
{% endtabs %}
