Konfigurieren eines Smarthosts oder Relayhosts
Bemerkung: The terms smarthost and relayhost are usually used interchangeably. We will stick to the term smarthost from here on.
Inhalt: You can configure a smarthost starting from Plesk Obsidian 18.0.64. In this topic, you will learn the following:
- Wann ist die Verwendung eines Smarthosts sinnvoll?
- How to configure a smarthost in Plesk.
- How configuring a smarthost will affect an existing manual configuration.
- How Plesk changes mail services‘ configuration files when setting up a smarthost.
You can send emails directly from Plesk via its local SMTP server. However, hosting providers can forbid sending emails from local SMTP servers. And even if they allow it, the deliverability of such emails may not be good and they can land in spam. The solution for this issue is to configure a smarthost.
Ein Smarthost ist ein Mailserver, der so konfiguriert ist, dass er E-Mails von beliebigen Absendern annimmt und sie dann an das entsprechende Ziel weiterleitet. Ein Smarthost fungiert als Vermittler, um die Wahrscheinlichkeit zu erhöhen, dass E-Mails ihr Ziel erreichen, ohne im Spam zu landen.
When you send an email through a smarthost, it looks as if the email originated from the smarthost IP address. And if the smarthost has a good reputation, the email is more likely to reach the recipient’s inbox. For this reason, it is recommended to use a reputable SMTP relay service as a smarthost (for example, SendGrid, Mailgun, Mailjet, and so on).
Previously, Plesk did not offer the ability to configure a smarthost. Users had to configure a smarthost manually at their own discretion.
Starting from Plesk Obsidian 18.0.64, you can configure a smarthost in the Plesk graphical interface and via the CLI.
Konfigurieren eines Smarthosts
Configuring a smarthost is a server-wide feature. It works in Plesk for Linux with Postfix and Plesk for Windows with either MailEnable or SmarterMail.
Vorsicht: If you have already configured a smarthost manually, enabling the smarthost feature in Plesk will overwrite your existing configuration. Before enabling the feature, we recommend that you refer to the following section first.
Bemerkung: With some SMTP relay services (for example, SendGrid), mail forwarding will no longer work if a smarthost is configured.
So konfigurieren Sie einen Smarthost:
-
Choose a reputable SMTP relay service (for example, SendGrid, Mailgun, Mailjet, or any other) and create an account there.
-
Go to Tools & Settings > Smarthost (under „Mail“).
-
Select the „Send users‘ mail via a smarthost“ checkbox.
-
Geben Sie im entsprechenden Feld die IP-Adresse oder den Hostnamen eines Smarthosts an (zum Beispiel
192.0.2.1
odersmtp.sendgrid.net
).Bemerkung: In Plesk for Linux, you can disable MX or SRV lookups by putting the hostname or IP address in square brackets, for example,
[example.com]
. For details, see the Postfix documentation (the section aboutrelayhost
). -
Wenn Ihr SMTP-Relay-Dienst eine SMTP-Authentifizierung erfordert (was bei den meisten Diensten der Fall ist), aktivieren Sie das Kontrollkästchen „Authentifizierung erforderlich“.
-
If you have selected „Authentication required“ during the previous step, specify the credentials to authenticate to your SMTP relay service.
If the service supports basic authentication, specify the username and password in the corresponding fields. If the service supports authentication via API keys, in the „Username“ field, specify the default username used for API keys in the service (for example, in SendGrid, the username is
apikey
) and, in the „Password“ field, specify the API key value. -
In the „Encrypted connection“ section, select whether to encrypt the credentials transmitted to the SMTP relay service. The exact options differ between Linux and Windows:
- (Plesk for Linux) Choose if the encrypted connection is required or not.
- (Plesk for Windows) Choose if the encrypted connection is required or not. And if it is, choose the encryption type: TLS or SSL.
Bemerkung: Wenn Sie einen Verbindungstyp wählen, der vom SMTP-Relay-Dienst nicht unterstützt wird (z. B. keine Verschlüsselung anstelle von TLS), wird die Verbindung zum Smarthost nicht hergestellt.
-
(Optional) You may want to check if the connection to the smarthost can be established. To do so, click Check Connection.
If you have selected „Encrypted connection“ in the previous step, the connection will be tested not only for encryption but also for a valid SSL/TLS certificate. And if the connection is encrypted but the SSL/TLS certificate is not trusted (for example, expired or self-signed), the connection will not be established.
Bemerkung: You can change the default behaviour described above and allow to establish the connection even if it is not secured by a valid SSL/TLS certificate.
-
Klicken Sie auf OK.
-
Update the SPF and other related DNS records in the DNS template and in the DNS zones of existing domains. SMTP relay services provide the information what DNS changes to make.
You have configured the smarthost on the Plesk side. However, most commercial SMTP relay services require domain authentication on their side (can also be called domain verification). The following SMTP relay services require it: SendGrid, Mailjet, Mailgun.
-
Go to your SMTP relay service account and authenticate all domains hosted in Plesk. For exact steps on how to do so, refer to the documentation of your service.
-
Send a test email to an external email service (for example, Gmail) and make sure that the email has reached the inbox.
You have configured the smarthost both in Plesk and your SMTP relay service. Your smarthost is now up and running.
Konfigurieren eines Smarthosts nach einer vorherigen manuellen Konfiguration
If you have already configured a smarthost manually, enabling the smarthost feature in Plesk will overwrite your existing configuration. Although Plesk applies the most common configuration suited for most smarthost services, you may need to tinker with the configuration to tailor it to your smarthost.
Wenn Sie bereits einen Smarthost manuell konfiguriert haben, empfehlen wir Ihnen den folgenden Algorithmus:
- Vergleichen Sie beide Smarthost-Konfigurationen: Ihre manuelle und die von Plesk.
- Remove the parameters that will be controlled by Plesk from your manual configuration.
- Keep additional parameters not covered by Plesk as it is.
- Enable the smarthost feature in Plesk.
To help you compare both configurations, below we describe how the smarthost feature works under the hood: which configuration files it affects and in what way.
(Plesk für Linux) Smarthost-Konfiguration mit Postfix
Bemerkung: Wenn Sie bereits benutzerdefinierte Smarthosts für Domains konfiguriert haben, haben diese Vorrang vor dem serverweiten Smarthost von Plesk.
When you enable the smarthost feature, Plesk performs the following actions under the hood:
-
Adds lines of the following pattern to the
/etc/postfix/main.cf
configuration file:# Sets an external SMTP relayhost with a port number relayhost - [Your-SMTP-server-IP-or-hostname]:587 # Turns on TLS encryption smtp_tls_security_level = encrypt # Turns on authentication smtp_sasl_auth_enable = yes # Sets the username and password required for authentication smtp_sasl_password_maps = /var/spool/postfix/plesk/relay_secrets # Prohibits anonymous authentication methods. smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous
-
Checks that
/etc/postfix/main.cf
contains no duplicate directives, which can break the configuration:cat /etc/postfix/main.cf | grep -E "relayhost|smtp_sasl_auth_enable|smtp_sasl_password_maps|smtp_sasl_security_options|smtp_sasl_tls_security_options|smtp_tls_security_level"
-
Configures the API authentication to the SMTP relay service of your choice via the
/etc/postfix/sasl_passwd
file. For example, with the SendGrid service, the following line will be added:[smtp.sendgrid.net]:2525 apikey:<your-SendGrid-API-key-value>
-
Uses the
postmap
utility to generate the.db
configuration file:postmap /etc/postfix/sasl_passwd
-
Reloads the Postfix service to apply the changes:
systemctl reload postfix
(Plesk für Windows) Smarthost-Konfiguration mit MailEnable
When you enable the smarthost feature, Plesk applies the MailEnable configuration shown on the screenshot below. We use the SendGrid SMTP relay service as an example.
Bemerkung: Wenn Sie bereits benutzerdefinierte Smarthosts für Domains konfiguriert haben, haben diese Vorrang vor dem serverweiten Smarthost von Plesk.
(Plesk für Windows) Smarthost-Konfiguration mit SmarterMail
When you enable the smarthost feature, Plesk applies the SmarterMail configuration shown on the screenshots below. We use the SendGrid SMTP relay service as an example.
The first screenshot shows the server-wide configuration, while the second one—the configuration for domains.
Bemerkung: Wenn Sie bereits benutzerdefinierte Smarthosts für Domains konfiguriert haben, hat der serverweite Plesk-Smarthost Vorrang vor diesen.
Deaktivieren der Smarthost-Funktion
Sie können die Smarthost-Funktion deaktivieren, indem Sie sie in der grafischen Oberfläche von Plesk ausblenden.
So deaktivieren Sie die Smarthost-Funktion:
-
Öffnen Sie die Datei panel.ini, um sie zu bearbeiten. Sie finden sie hier:
- (Plesk für Linux)
/usr/local/psa/admin/conf/panel.ini
- (Plesk für Windows)
%plesk_dir%admin\conf\panel.ini
Sie können die Datei in der Plesk Oberfläche auch über die Erweiterung Panel.ini Editor bearbeiten.
- (Plesk für Linux)
-
Fügen Sie die folgenden Zeilen zur Datei
panel.ini
hinzu und speichern Sie sie:[mail] smarthost.server.enabled = false
Die Smarthost-Funktion wird nicht mehr in Tools & Einstellungen angezeigt.
Bemerkung: You can also disable the smarthost feature by enabling Restricted Mode.
Disable the SSL/TLS Certificate Check Bound With the Check Connection Button
By default, if the connection to a smarthost requires encryption, clicking the Check Connection button will also check if the connection is secured with a valid SSL/TLS certificate. And if it is not, the connection to the smarthost will not be established.
If you want to establish the connection even if an SSL/TLS certificate is not trusted (for example, expired or self-signed), you can disable the check of the certificate.
To disable the check of an SSL/TLS certificate bound with the Check Connection button:
-
Öffnen Sie die Datei panel.ini, um sie zu bearbeiten. Sie finden sie hier:
- (Plesk für Linux)
/usr/local/psa/admin/conf/panel.ini
- (Plesk für Windows)
%plesk_dir%admin\conf\panel.ini
Sie können die Datei in der Plesk Oberfläche auch über die Erweiterung Panel.ini Editor bearbeiten.
- (Plesk für Linux)
-
Fügen Sie die folgenden Zeilen zur Datei
panel.ini
hinzu und speichern Sie sie:[mail] smarthost.server.checkConnection.checkCertificate = false
You can now establish the connection with a smarthost which is not secured with a valid SSL/TLS certificate.