Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
tutoriaux:install-email-server:install-email-server-part-2 [2023/01/06 16:41] – supprimée - modification externe (Unknown date) 127.0.0.1 | tutoriaux:install-email-server:install-email-server-part-2 [2024/07/06 01:16] (Version actuelle) – frater | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Part 2 - IMAP and TLS Setup ====== | ||
+ | This is part 2 of building your own secure email server on Debian from scratch tutorial series. In [[tutoriaux: | ||
+ | |||
+ | To be able to send emails using a desktop email client, we need to enable the submission service in Postfix. | ||
+ | To receive emails using a desktop email client, we can install an open-source IMAP server named Dovecot on the Debian server. | ||
+ | And to encrypt our communications, | ||
+ | |||
+ | This part is focused only on **Canonical users** (use only local OS user as mailbox login) | ||
+ | ===== Open Ports in Firewall ===== | ||
+ | |||
+ | Debian doesn’t enable firewall by default. If you have enabled the UFW firewall, then you need to run the following command to open email related ports in firewall. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | If you use POP3 to fetch emails (I personally don’t), then also open port 110 and 995, you may also open unsecure IMAP port 143 (I personnaly don' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | ==== Ports ID and description ==== | ||
+ | |||
+ | ^ Port ^ TCP/ | ||
+ | | 80 | TCP | Web Server HTTP | | ||
+ | | 443 | TCP | Web Server HTTPS | | ||
+ | | 587 | TCP | SMTP | | ||
+ | | 465 | TCP | SMTP-SSL | ||
+ | | 143 | TCP | IMAP | | ||
+ | | 993 | TCP | IMAP-SSL | ||
+ | | 110 | TCP | POP3 | | ||
+ | | 995 | TCP | POP3-SSL | ||
+ | |||
+ | ===== Securing Email Server Traffic with TLS Certificate ===== | ||
+ | |||
+ | When we configure our desktop email clients, It’s always a good idea to enable TLS encryption to prevent hackers from snooping on our emails. We can easily obtain a free TLS certificate from Let’s Encrypt. Issue the following commands to install Let’s Encrypt client (certbot) on Debian server from the default software repository. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | sudo apt dist-upgrade | ||
+ | |||
+ | sudo apt install certbot</ | ||
+ | |||
+ | If you don’t have a web server running yet, I recommend you install one (Apache or Nginx), because it’s easier to obtain and install TLS certificate with a web server than using other methods. And in a later tutorial, I will show you how to set up webmail, which requires running a web server. | ||
+ | |||
+ | If you choose to use Apache web server, you need to install the Apache plugin. (The following command will install Apache web server if it’s not already installed on your system.) | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | If you choose use Nginx web server, then install the Nginx plugin. (The following command will install Nginx web server if it’s not already installed on your system.) | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | ==== Obtaining TLS Certificate with Apache Web Server ==== | ||
+ | |||
+ | We create an Apache virtual host for mail.example.com before obtaining Let’s Encrypt TLS certificate. Create the virtual host file: | ||
+ | |||
+ | <code bash> | ||
+ | sudo nano / | ||
+ | </ | ||
+ | |||
+ | Then paste the following text into the file. | ||
+ | |||
+ | <code apache> | ||
+ | < | ||
+ | ServerName mail.example.com | ||
+ | |||
+ | DocumentRoot / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Save and close the file. Enable this virtual host. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Then disable the default virtual host, because it might interfere with other virtual hosts. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Reload Apache for the changes to take effect. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Once the virtual host is created and enabled, run the following command to obtain Let’s Encrypt TLS certificate. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Where: | ||
+ | |||
+ | ^ certonly | ||
+ | ^ --apache | ||
+ | ^ --agree-tos | ||
+ | ^ --no-eff-email | ||
+ | ^ --staple-ocsp | ||
+ | ^ --email | ||
+ | ^ -d | domain, aka your mail server hostname. | ||
+ | |||
+ | Substitute the " | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | ==== Obtaining TLS Certificate with Nginx Web Server ==== | ||
+ | |||
+ | We create an Nginx virtual host for '' | ||
+ | |||
+ | <code bash> | ||
+ | sudo nano / | ||
+ | </ | ||
+ | |||
+ | Next, paste the following text into the file. | ||
+ | |||
+ | <code apache> | ||
+ | server { | ||
+ | listen 80; | ||
+ | listen [::]:80; | ||
+ | server_name mail.example.com; | ||
+ | |||
+ | root / | ||
+ | |||
+ | location ~ / | ||
+ | allow all; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Save and close the file. Make sure the ''/ | ||
+ | |||
+ | <code bash> | ||
+ | sudo mkdir -p / | ||
+ | </ | ||
+ | |||
+ | Reload Nginx for the changes to take effect. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Once the virtual host is created and enabled, run the following command to obtain Let’s Encrypt certificate with Nginx plugin. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Where: | ||
+ | |||
+ | ^ certonly | ||
+ | ^ --nginx | ||
+ | ^ --agree-tos | ||
+ | ^ --no-eff-email | ||
+ | ^ --staple-ocsp | ||
+ | ^ --email | ||
+ | ^ -d | domain, aka your mail server hostname. | ||
+ | |||
+ | |||
+ | You should see the following which means the certificate is successfully obtained. You can also see the directory under which your cert is stored. | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | ===== Enable Submission Service in Postfix ===== | ||
+ | To send emails from a desktop email client, we need to enable the submission service of Postfix so that the email client can submit emails to Postfix SMTP server. Edit the '' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | In '' | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | <code ini> | ||
+ | submission | ||
+ | -o syslog_name=postfix/ | ||
+ | -o smtpd_tls_security_level=encrypt | ||
+ | -o smtpd_tls_wrappermode=no | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_relay_restrictions=permit_mynetworks, | ||
+ | -o smtpd_recipient_restrictions=permit_mynetworks, | ||
+ | -o smtpd_sasl_type=dovecot | ||
+ | -o smtpd_sasl_path=private/ | ||
+ | </ | ||
+ | |||
+ | **Some explainations** | ||
+ | {{tablelayout? | ||
+ | ^ parameter | ||
+ | | syslog_name | ||
+ | | smtpd_tls_security_level | ||
+ | | smtpd_tls_wrappermode | ||
+ | | smtpd_relay_restrictions | ||
+ | | smtpd_recipient_restrictions | ||
+ | | smtpd_sasl_type | ||
+ | | smtpd_sasl_path | ||
+ | |||
+ | <WRAP center round tip> | ||
+ | An alternative is to be more restrictive on what your ' | ||
+ | |||
+ | In this case, the trusted network (mynetworks) is only allowed to send | ||
+ | <code ini> | ||
+ | submission | ||
+ | : | ||
+ | -o smtpd_relay_restrictions=permit_sasl_authenticated, | ||
+ | -o smtpd_recipient_restrictions=permit_mynetworks, | ||
+ | : | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | The above configuration enables the **submission** daemon of Postfix and requires TLS encryption. So later on our desktop email client can connect to the submission daemon in TLS encryption. The submission daemon listens on TCP port **587**. STARTTLS is used to encrypt communications between email client and the submission daemon. | ||
+ | |||
+ | //Microsoft Outlook// mail client only supports submission over port **465**. If you are going to use Microsoft Outlook, then you also need to enable submission service on port 465 by adding the following lines in the file. | ||
+ | |||
+ | <code ini> | ||
+ | smtps | ||
+ | -o syslog_name=postfix/ | ||
+ | -o smtpd_tls_wrappermode=yes | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_relay_restrictions=permit_sasl_authenticated, | ||
+ | -o smtpd_recipient_restrictions=permit_mynetworks, | ||
+ | -o smtpd_sasl_type=dovecot | ||
+ | -o smtpd_sasl_path=private/ | ||
+ | </ | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | <WRAP round tip> | ||
+ | The SMTP protocol is used when an email client submits emails to an SMTP server. | ||
+ | </ | ||
+ | |||
+ | Next, we need to specify the location of TLS certificate and private key in Postfix configuration file. Edit '' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Edit the TLS parameter as follows. Remember to replace '' | ||
+ | |||
+ | <code apache> | ||
+ | # TLS parameters | ||
+ | # Let's Encrypt certificate | ||
+ | smtpd_tls_cert_file=/ | ||
+ | smtpd_tls_key_file=/ | ||
+ | smtpd_tls_CAfile=/ | ||
+ | |||
+ | smtpd_tls_security_level=may | ||
+ | smtpd_tls_loglevel = 1 | ||
+ | smtpd_tls_session_cache_database = btree: | ||
+ | |||
+ | #Enable TLS Encryption when Postfix sends outgoing emails | ||
+ | smtp_tls_security_level = may | ||
+ | smtp_tls_loglevel = 1 | ||
+ | smtp_tls_session_cache_database = btree: | ||
+ | |||
+ | #Enforce TLSv1.3 or TLSv1.2 | ||
+ | smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 | ||
+ | smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 | ||
+ | smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 | ||
+ | smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 | ||
+ | </ | ||
+ | |||
+ | Your Let’s Encrypt certificate and private key are stored under ''/ | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | Save and close the file. Then restart Postfix. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | If you run the following command, you will see Postfix is now listening on port 587 and 465. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | ===== Installing Dovecot IMAP Server ===== | ||
+ | Enter the following command to install Dovecot core package and the IMAP daemon package on Debian server. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | If you use POP3 to fetch emails, then also install the dovecot-pop3d package. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Check Dovecot version: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Sample output: | ||
+ | |||
+ | < | ||
+ | |||
+ | ===== Define your email network ===== | ||
+ | |||
+ | By default, Postfix will forward mail from clients in authorized network blocks to any destination. | ||
+ | |||
+ | The current default is to authorize the local machine only. | ||
+ | |||
+ | Prior to Postfix 3.0, the default was to authorize all clients in the IP subnetworks that the local machine is attached to. | ||
+ | |||
+ | <WRAP center round important> | ||
+ | changing the definition of the authorized network block is generaly a bad idea, you MUST know what your define and who you trust. | ||
+ | </ | ||
+ | |||
+ | Sometime you need to " | ||
+ | |||
+ | the correct parameter is | ||
+ | |||
+ | <code ini> | ||
+ | mynetworks = [list of IPs separated by comma] | ||
+ | </ | ||
+ | |||
+ | ===== Enabling IMAP/POP3 Protocol ===== | ||
+ | Edit the main config file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Add the following line to enable IMAP protocol. | ||
+ | |||
+ | < | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | If you use POP3 to fetch emails, then also add POP3 protocol. | ||
+ | |||
+ | < | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | ===== Configuring Mailbox Location ===== | ||
+ | By default, Postfix and Dovecot use mbox format to store emails. Each user’s emails are stored in a single file ''/ | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Sample output: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | However, nowadays it’s almost always you want to use the Maildir format to store email messages. The config file for mailbox location is ''/ | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | The default configuration uses mbox mail format. | ||
+ | |||
+ | < | ||
+ | |||
+ | Change it to the following to make Dovecot use the Maildir format. Email messages will be stored under the '' | ||
+ | |||
+ | < | ||
+ | |||
+ | Save and close the file. Then add dovecot to the mail group so that Dovecot can read the INBOX. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | |||
+ | ===== Using Dovecot to Deliver Email to Message Store ===== | ||
+ | |||
+ | Although we configured Dovecot to store emails in Maildir format, by default, Postfix uses its built-in local delivery agent (LDA) to move inbound emails to the message store (inbox, sent, trash, Junk, etc), and it will be saved in '' | ||
+ | |||
+ | We need to configure Postfix to pass incoming emails to Dovecot, via the LMTP protocol, which is a simplified version of SMTP, so incoming emails will saved in '' | ||
+ | |||
+ | ==== Install the Dovecot LMTP Server. ==== | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Edit the Dovecot main configuration file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Add '' | ||
+ | |||
+ | <code apache> | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | Save and close the file. Then edit the Dovecot 10-master.conf file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Change the '' | ||
+ | |||
+ | <code apache> | ||
+ | service lmtp { | ||
+ | | ||
+ | mode = 0600 | ||
+ | user = postfix | ||
+ | group = postfix | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | Next, edit the Postfix main configuration file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Add the following lines at the end of the file. The first line tells Postfix to deliver incoming emails to local message store via the Dovecot LMTP server. The second line disables SMTPUTF8 in Postfix, because Dovecot-LMTP doesn’t support this email extension. | ||
+ | |||
+ | <code apache> | ||
+ | mailbox_transport = lmtp: | ||
+ | smtputf8_enable = no | ||
+ | </ | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | ===== Configuring User Authentication Mechanism ===== | ||
+ | Edit the authentication config file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Uncomment the following line. | ||
+ | |||
+ | <code apache> | ||
+ | |||
+ | It will disable plaintext authentication when there’s no SSL/TLS encryption. Then find the following line, | ||
+ | |||
+ | <code apache> | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | Uncomment it and change its value to '' | ||
+ | |||
+ | <code apache> | ||
+ | |||
+ | By default, when Dovecot tries to find or deliver emails for a user, it uses the full email address. Since in this part, we only set up **canonical mailbox users** (using OS users as mailbox users), Dovecot can’t find the mailbox user in full domain format (username@example.com), | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | Next, find the following line. | ||
+ | |||
+ | <code apache> | ||
+ | |||
+ | This line only enables the PLAIN authentication mechanism. LOGIN is another authentication mechanism you probably want to add to support older email clients. | ||
+ | |||
+ | <code apache> | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | ===== Configuring SSL/TLS Encryption ===== | ||
+ | |||
+ | Edit SSL/TLS config file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Change ssl = yes to ssl = required to enforce encryption. | ||
+ | |||
+ | <code apache> | ||
+ | Then find the following lines. | ||
+ | |||
+ | <code apache> | ||
+ | ssl_cert = </ | ||
+ | ssl_key = </ | ||
+ | </ | ||
+ | By default, Dovecot uses a self-signed TLS certificate. Replace them with the following values, which specify the location of your Let’s Encrypt TLS certificate and private key. Don’t leave out the < character. It’s necessary. | ||
+ | <code apache> | ||
+ | ssl_cert = </ | ||
+ | ssl_key = </ | ||
+ | </ | ||
+ | |||
+ | Find the following line. | ||
+ | |||
+ | <code apache> | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | It’s a good practice to prefer the server’s order of ciphers over client’s. So uncomment this line and change the value to yes. | ||
+ | |||
+ | <code apache> | ||
+ | ssl_prefer_server_ciphers = yes | ||
+ | </ | ||
+ | |||
+ | Then find the following line. | ||
+ | |||
+ | <code apache> | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | Change it to the following to disable insecure SSLv3, TLSv1, and TLSv1.1 protocols. | ||
+ | |||
+ | <code apache> | ||
+ | ssl_min_protocol = TLSv1.2 | ||
+ | </ | ||
+ | |||
+ | Save and close the file. | ||
+ | ===== Configuring SASL Authentication ===== | ||
+ | Edit the following file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Change '' | ||
+ | |||
+ | <code python> | ||
+ | service auth { | ||
+ | unix_listener / | ||
+ | mode = 0660 | ||
+ | user = postfix | ||
+ | group = postfix | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Save and close the file. | ||
+ | |||
+ | After you save and close all the above config files, restart Postfix and Dovecot. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Dovecot will be listening on port 143 (IMAP) and 993 (IMAPS), as can be seen with: | ||
+ | |||
+ | < | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | If there’s a configuration error, dovecot will fail to restart, so it’s a good idea to check if Dovecot is running with the following command. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | ===== Configure Desktop Email Client ===== | ||
+ | |||
+ | Now open up your desktop email client such as Mozilla Thunderbird. Go to **Edit** -> **Account Settings** -> **Account Actions** -> **Add Mail Account** to add a mail account. | ||
+ | |||
+ | In the incoming server section, select IMAP protocol, enter '' | ||
+ | In the outgoing section, select SMTP protocol, enter '' | ||
+ | |||
+ | [[..: | ||
+ | |||
+ | <WRAP round tip> | ||
+ | You can also use port 993 with SSL/TLS encryption for IMAP, and use port 465 with SSL/TLS encryption for SMTP. You should NOT use port 25 as the SMTP port in mail clients to submit outgoing emails. | ||
+ | </ | ||
+ | |||
+ | You should now be able to connect to your own email server and also send and receive emails with your desktop email client! | ||
+ | |||
+ | We use local Unix accounts as email addresses, as we did in [[tutoriaux: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Note: Dovecot doesn’t allow you to log in with the '' | ||
+ | |||
+ | You can list all available mailbox users with: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | It’s recommended to restart Dovecot after adding users, so Dovecot can recognize new mailbox users. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | ==== Troubleshooting Tips ==== | ||
+ | |||
+ | As a rule of thumb, you should always check the mail log (''/ | ||
+ | |||
+ | === Can’t login from Mail Clients === | ||
+ | |||
+ | If you can’t log into your mail server from a desktop mail client, scan your mail server to find if the ports (TCP 587, 465, 143, and 993) are open. Note that you should run the following command from another Linux computer or server. If you run it on your mail server, then the ports will always appear to be open. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | And check if Dovecot is running. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | You can also check the mail log (''/ | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | For example, some folks may have the following error in the journal. | ||
+ | |||
+ | < | ||
+ | |||
+ | Most of the time, it’s a simple syntax error, like a missing curly bracket. Open the configuration file, go to the specified line and fix the error. | ||
+ | |||
+ | If you find the following error message in the mail log | ||
+ | |||
+ | < | ||
+ | |||
+ | Then open the Dovecot TLS configuration file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Add the following line in this file. | ||
+ | |||
+ | < | ||
+ | |||
+ | Save and close the file. Then generate the DH parameter file with: | ||
+ | |||
+ | <code bash> | ||
+ | Restart Dovecot for the changes to take effect. | ||
+ | |||
+ | === Cloudflare DNS === | ||
+ | |||
+ | As I said in [[tutoriaux: | ||
+ | |||
+ | === Relay Access Denied === | ||
+ | |||
+ | If you see the “**relay access denied**” error when trying to send emails from a mail client, it’s most likely that you use port 25 as the SMTP port in your mail client. As I said a while ago, you should use port **587** or **465** as the SMTP port in mail clients (Mozilla Thunberbird, | ||
+ | |||
+ | [[..: | ||
+ | |||
+ | If you see the following “**relay access denied**” error in the ''/ | ||
+ | |||
+ | < | ||
+ | |||
+ | You can display the current value of '' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Some folks might not have the main domain name in the list like so: | ||
+ | |||
+ | < | ||
+ | |||
+ | Then run the following command to add the main domain name to the list. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Reload Postfix for the changes to take effect. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | === User Doesn’t Exist === | ||
+ | |||
+ | If you see the following error message in the mail log (''/ | ||
+ | |||
+ | < | ||
+ | mail postfix/ | ||
+ | </ | ||
+ | |||
+ | === iOS Mail App === | ||
+ | |||
+ | If you use the iOS Mail app to log into your mail server and encounter the following error. | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | You can try to fix it by enforcing SSL encryption, for both SMTP and IMAP. | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | <WRAP round todo> | ||
+ | Fun fact: It seems the iOS Mail app has difficulty in supporting STARTTLS on IMAP port 143, but it supports STARTTLS on the submission port 587. | ||
+ | </ | ||
+ | |||
+ | If you encounter the “No password provided” error in the iOS Mail app, it’s likely that you have a typo when entering the username in the Mail account settings, or you didn’t enable SSL in the Mail account settings. | ||
+ | |||
+ | {{ tutoriaux: | ||
+ | |||
+ | === Unable to Receive Email From Gmail, Hotmail, Yahoo Mail, etc === | ||
+ | |||
+ | If you can’t receive emails from Gmail, Hotmail, Yahoo Mail, etc, here are the possible causes: | ||
+ | |||
+ | - Your MX record is wrong, or not propagated to the Internet yet. | ||
+ | - Your mail server hostname doesn’t have DNS A record, or not propagated to the Internet yet. | ||
+ | - Your firewall doesn’t allow incoming connection to port 25. Maybe your mail server is behind a NAT? | ||
+ | - Postfix isn’t listening on the public IP address. | ||
+ | - Check the mail log (''/ | ||
+ | |||
+ | |||
+ | You can use the [[https:// | ||
+ | |||
+ | [[..: | ||
+ | |||
+ | If your SMTP servers isn’t reachable from the Internet, then you have a problem in the first 4 items. If your SMTP server is reachable from the Internet, but you still can’t receive emails, check the mail log (''/ | ||
+ | |||
+ | ===== Auto-Renew TLS Certificate ===== | ||
+ | You can create Cron job to automatically renew TLS certificate. Simply open root user’s crontab file. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | If you use **Apache** web server, add the following line at the bottom of the file. | ||
+ | |||
+ | < | ||
+ | |||
+ | If you are using **Nginx** web server, then add the following line. | ||
+ | |||
+ | < | ||
+ | |||
+ | Reloading Postfix, Dovecot and the web server is necessary to make these programs pick up the new certificate and private key. | ||
+ | |||
+ | ===== Dovecot Automatic Restart ===== | ||
+ | If for any reason your Dovecot process is killed, you need to run the following command to restart it. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Instead of manually typing this command, we can make Dovecot automatically restart by editing the '' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Then create a file under this directory. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Add the following lines in the file, which will make Dovecot automatically restart 5 seconds after a failure is detected. | ||
+ | |||
+ | < | ||
+ | [Service] | ||
+ | Restart=always | ||
+ | RestartSec=5s | ||
+ | </ | ||
+ | |||
+ | Save and close the file. Then reload systemd for the changes to take effect. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | To check if this would work, kill Dovecot with: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Then check Dovecot status. You will find Dovecot automatically restarted. | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | {{page> |