doc/pages/01.administer/09.tutorials/07.email_relay/email_configure_relay.md

84 lines
5.4 KiB
Markdown
Raw Normal View History

2021-02-06 15:15:00 +01:00
---
title: Configure SMTP relay
template: docs
taxonomy:
category: docs
2021-02-06 18:03:27 +01:00
routes:
default: '/email_configure_relay'
2021-07-31 21:18:36 +02:00
aliases:
- '/smtp_relay'
2021-02-06 15:15:00 +01:00
---
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
If your ISP blocks port 25, if you can't set a reverseDNS on your server, or if you have any other troubles using the built-in SMTP server on YunoHost, you may want to setup your YunoHost server to use an SMTP relay.
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
## What is an SMTP relay?
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
An SMTP relay is basically a third party hosted SMTP server that will send emails on behalf of your own SMTP server (Postfix service on YunoHost).
Once setup correctly on YunoHost, its operation is transparent, both for you and for your correspondents: they will see emails as coming from your YunoHost main URL, but all the sending will be delegated to the SMTP relay you have chosen and configured.
2020-12-30 20:37:24 +01:00
2021-06-06 17:30:09 +02:00
## [fa=exclamation-triangle /] Disadvantages of SMTP relays
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
It's important to note that using an SMTP relay has to be seen as a (big) compromise in the world of self-hosting. Indeed, when using an SMTP relay, not only a third party sends emails on your behalf, but it has full access to the content of all the emails you'll send and can also possibly modify them (For example, by default, MailJet rewrites the html hyperlinks contained in your emails, in order to track the activity of your correspondents). Be also aware that an SMTP relay is setup for your whole YunoHost server: you can't choose which emails or which users go through it because all future emails will.
2021-07-14 08:46:26 +02:00
Beyond the privacy considerations above, an SMTP relay can impose technical limitations that one would not have if port 25 was open. For example, with most relays, if a user of your YunoHost server declares **an external "forwarding address"** in order to automatically forward messages received on your YunoHost server to another mailbox, **such forwarding will not work** for emails originating from outside your server, without any warning. Indeed, relays generally require that the messages they forward have a sender address from your domain (to fight spam and preserve the reputation of their services), which is not the case for an "automatic forward" where the original sender of the mail is kept; the message is then blocked by the relay (which, normally, warns your YunoHost admin, but only afterwards)
2021-05-26 22:39:31 +02:00
## How to use an SMTP relay with YunoHost?
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
YunoHost has a built-in SMTP relay configuration, available from version 4.1. That configuration is not yet available from the admin web interface, though. You will have to use the command line interface.
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
### Step 1: Register with an SMTP relay provider
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
Many providers exist. Some have free plans with or without limitations, it's up to you. As written above, you have to be careful with your choice as you will basically handover all your emails to that third party. Whether you can trust it or not, that's your call!
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
### Step 2: Setup your DNS records correctly
2020-12-30 20:37:24 +01:00
Once registered, the SMTP relay provider will usually ask you to modify your DNS.
Standard procedure is to add a DKIM key and a SPF key to your DNS records.
The way to modify these records and the value of the keys you'll have to add depend both on your domain name provider and SMTP relay provider.
Usually, the SMTP relay provider will provide you with a guide on how to modify these records, together with an automatic check tool that will tell you when your DNS have been setup correctly. That step is mandatory to prove "the world" that you, owner of your domain name, did explicitly authorize your SMTP relay provider to send emails on your behalf.
2020-12-31 17:24:16 +01:00
Please note that modifying your DNS records could sometimes take over 24h to take effect, so be patient!
2020-12-30 20:37:24 +01:00
! [fa=exclamation-triangle /] From now on, a non trusty SMTP relay provider could send emails from your main domain without telling you.
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
### Step 3: Setup YunoHost correctly
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
In order to setup your YunoHost to use your SMTP relay, you will have to configure four things:
2020-12-31 17:24:16 +01:00
1. Your SMTP relay URL (for this tutorial we will use `smtprelay.tld`)
2021-05-26 22:39:31 +02:00
2. The port on which you access the relay (for this tutorial we will use port 2525 below)
3. Your SMTP relay username (for this tutorial we will use `username`)
4. Your SMTP relay password (for this tutorial we will use `password`)
2020-12-30 20:37:24 +01:00
2021-05-26 22:39:31 +02:00
Your SMTP relay will obviously provide you with these four things, that should be available in your control panel or whatsoever.
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
You can log into your YunoHost server using SSH:
2020-12-30 20:37:24 +01:00
```bash
2020-12-31 17:24:16 +01:00
ssh admin@yourdomain.tld
```
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
Then you can update the three values as below:
2020-12-30 20:37:24 +01:00
```bash
sudo yunohost settings set smtp.relay.host -v smtprelay.tld
2021-05-26 22:39:31 +02:00
sudo yunohost settings set smtp.relay.port -v 2525
2020-12-30 20:37:24 +01:00
sudo yunohost settings set smtp.relay.user -v username
sudo yunohost settings set smtp.relay.password -v password
```
2020-12-31 17:24:16 +01:00
It may be a good idea to double confirm your settings by doing:
2020-12-30 20:37:24 +01:00
```bash
sudo yunohost settings list
```
2020-12-31 17:24:16 +01:00
Your SMTP relay is now configured!
2020-12-30 20:37:24 +01:00
! [fa=exclamation-triangle /] From now on, a non trusty SMTP relay provider could read or use the data of all the emails you send without telling you (but still won't be able to read nor to use the data from emails you receive).
2020-12-30 20:37:24 +01:00
2020-12-31 17:24:16 +01:00
### Step 4: Check your setup
2020-12-30 20:37:24 +01:00
You can check your setup by sending emails and try if everything works.
Some of the SMTP relay will give you insights about the emails you send so that can also be a good way to check that everythings works as needed.
Of course, you can always have a try with [mail-tester.com](https://www.mail-tester.com/) to check for any problem or discrepancy.