Part 2: Install Dovecot IMAP server on Ubuntu & Enable TLS Encryption
This is part 2 of building your own secure email server on Ubuntu from scratch tutorial series. In part 1, we showed you how to set up a basic Postfix SMTP server. In this tutorial, we are going to configure our email server so that we can receive and send emails using a desktop email client like Mozilla Thunderbird or Microsoft Outlook.
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 Ubuntu server. And to encrypt our communications, we need a TLS certificate.
Open Ports in Firewall
Ubuntu 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.
sudo ufw allow 80,443,587,465,143,993/tcp
If you use POP3 to fetch emails (I personally don’t), then also open port 110 and 995.
sudo ufw allow 110,995/tcp
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 command to install Let’s Encrypt client (certbot) on Ubuntu server from the default software repository.
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 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.)
sudo apt install python3-certbot-apache
If you 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.)
sudo apt install python3-certbot-nginx
Obtaining TLS Certificate with Apache Web Server
You need to have an Apache virtual host for mail.your-domain.com
before obtaining Let’s Encrypt TLS certificate. Create the virtual host file:
sudo nano /etc/apache2/sites-available/mail.your-domain.com.conf
Then paste the following text into the file.
<VirtualHost *:80> ServerName mail.your-domain.com DocumentRoot /var/www/mail.your-domain.com </VirtualHost>
Save and close the file. Then create the web root directory.
sudo mkdir /var/www/mail.your-domain.com
Set www-data
(Apache user) as the owner of the web root.
sudo chown www-data:www-data /var/www/mail.your-domain.com -R
Enable this virtual host.
sudo a2ensite mail.your-domain.com.conf
Reload Apache for the changes to take effect.
sudo systemctl reload apache2
Once virtual host is created and enabled, run the following command to obtain Let’s Encrypt TLS certificate.
sudo certbot certonly -a apache --agree-tos --no-eff-email --staple-ocsp --email [email protected] -d mail.your-domain.com
Substitute the red text with your actual data. You should see the following which means the certificate is successfully obtained. You can also see the directory under which your cert is stored.
Obtaining TLS Certificate with Nginx Web Server
You need to have an Nginx virtual host for mail.your-domain.com
before obtaining Let’s Encrypt TLS certificate. Create the virtual host file:
sudo nano /etc/nginx/conf.d/mail.your-domain.com.conf
Next, paste the following text into the file.
server { listen 80; listen [::]:80; server_name mail.your-domain.com; root /var/www/mail.your-domain.com/; location ~ /.well-known/acme-challenge { allow all; } }
Save and close the file. Then create the web root directory.
sudo mkdir /var/www/mail.your-domain.com/
Set www-data
(Nginx user) as the owner of the web root.
sudo chown www-data:www-data /var/www/mail.your-domain.com -R
Reload Nginx for the changes to take effect.
sudo systemctl reload nginx
Once the virtual host is created and enabled, run the following command to obtain Let’s Encrypt certificate with Nginx plugin.
sudo certbot certonly -a nginx --agree-tos --no-eff-email --staple-ocsp --email [email protected] -d mail.your-domain.com
You should see the following which means the certificate is successfully obtained. You can also see the directory under which your cert is stored.
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 master.cf
file.
sudo nano /etc/postfix/master.cf
In submission
section, uncomment or add the following lines. Please allow at least one whitespace (tab or spacebar) before -o
. In postfix configurations, a preceding whitespace character means that this line is continuation of the previous line. (By default the submission
section is commented out. You can copy the following lines and paste them into the file, so you don’t have to manually uncomment or add new text.)
submission inet n - y - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_tls_wrappermode=no -o smtpd_sasl_auth_enable=yes -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject -o smtpd_sasl_type=dovecot -o smtpd_sasl_path=private/auth
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.
smtps inet n - y - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject -o smtpd_sasl_type=dovecot -o smtpd_sasl_path=private/auth
Save and close the file.
Hint: 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 main.cf
file.
sudo nano /etc/postfix/main.cf
Edit the TLS parameter as follows. Remember to replace mail.your-domain.com
with your real hostname.
#Enable TLS Encryption when Postfix receives incoming emails smtpd_tls_cert_file=/etc/letsencrypt/live/mail.your-domain.com/fullchain.pem smtpd_tls_key_file=/etc/letsencrypt/live/mail.your-domain.com/privkey.pem smtpd_tls_security_level=may smtpd_tls_loglevel = 1 smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache #Enable TLS Encryption when Postfix sends outgoing emails smtp_tls_security_level = may smtp_tls_loglevel = 1 smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache #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 /etc/letsencrypt/live/mail.your-domain.com/
directory.
Save and close the file. Then restart Postfix.
sudo systemctl restart postfix
If you run the following command, you will see Postfix is now listening on port 587 and 465.
sudo ss -lnpt | grep master
Installing Dovecot IMAP Server
Enter the following command to install Dovecot core package and the IMAP daemon package on Ubuntu server.
sudo apt install dovecot-core dovecot-imapd
If you use POP3 to fetch emails, then also install the dovecot-pop3d
package.
sudo apt install dovecot-pop3d
Check Dovecot version:
dovecot --version
Sample output:
2.2.22 (fe789d2)
Enabling IMAP/POP3 Protocol
Edit the main config file.
sudo nano /etc/dovecot/dovecot.conf
Add the following line to enable IMAP protocol.
protocols = imap
If you use POP3 to fetch emails, then also add POP3 protocol.
protocols = imap pop3
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 /var/mail/username
. You can run the following command to find the mail spool directory.
postconf mail_spool_directory
Sample output:
mail_spool_directory = /var/mail
However, nowadays it’s almost always you want to use the Maildir
format to store email messages. The config file for mailbox location is /etc/dovecot/conf.d/10-mail.conf
.
sudo nano /etc/dovecot/conf.d/10-mail.conf
The default configuration uses mbox
mail format.
mail_location = mbox:~/mail:INBOX=/var/mail/%u
Change it to the following to make Dovecot use the Maildir
format. Email messages will be stored under the Maildir
directory under each user’s home directory.
mail_location = maildir:~/Maildir
We need to add the following line in the file. (On Ubuntu 18.04 and 20.04, this line is already in the file.)
mail_privileged_group = mail
Save and close the file. Then add dovecot to the mail
group so that Dovecot can read the INBOX.
sudo adduser dovecot mail
Configuring Authentication Mechanism
Edit the authentication config file.
sudo nano /etc/dovecot/conf.d/10-auth.conf
Uncomment the following line.
disable_plaintext_auth = yes
It will disable plaintext authentication when there’s no SSL/TLS encryption. And if you want to use full email address ([email protected]) to login, add the following line in the file.
auth_username_format = %n
Otherwise, you are able to login with username only (without @your-domain.com). Next, find the following line.
auth_mechanisms = plain
This line only enables the PLAIN authentication mechanism. LOGIN is another authentication mechanism you probably want to add to support older email clients.
auth_mechanisms = plain login
Save and close the file.
Configuring SSL/TLS Encryption
Next, edit SSL/TLS config file.
sudo nano /etc/dovecot/conf.d/10-ssl.conf
Change ssl = yes to ssl = required to enforce encryption.
ssl = required
Then find the following lines.
ssl_cert = </etc/dovecot/private/dovecot.pem ssl_key = </etc/dovecot/private/dovecot.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.
ssl_cert = </etc/letsencrypt/live/mail.your-domain.com/fullchain.pem ssl_key = </etc/letsencrypt/live/mail.your-domain.com/privkey.pem
Find the following line.
#ssl_prefer_server_ciphers = no
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
.
ssl_prefer_server_ciphers = yes
We can also disable inscure SSLv3, TLSv1 and TLSv1.1 by adding the following line.
ssl_protocols = !SSLv3 !TLSv1 !TLSv1.1
Note: If you are using Dovecot version 2.3.x or above (as in Ubuntu 20.04), then you should add the following line instead, which will force Dovecot to use TLSv1.2 or TLSv1.3. Please don’t add this line if you use Dovecot version 2.2.x.
ssl_min_protocol = TLSv1.2
Save and close the file.
Configuring SASL Authentication
Edit the following file.
sudo nano /etc/dovecot/conf.d/10-master.conf
Change service auth
section to the following so that Postfix can find the Dovecot authentication server. Please be careful about the syntax. Every opening bracket should be terminated by a closing bracket.
service auth { unix_listener /var/spool/postfix/private/auth { mode = 0660 user = postfix group = postfix } }
Save and close the file.
Auto-create Sent and Trash Folder
Edit the below config file.
sudo nano /etc/dovecot/conf.d/15-mailboxes.conf
To auto-create a folder, simply add the following line in the mailbox section.
auto = create
Example:
mailbox Trash { auto = create special_use = \Trash }
Some common folders you will want to create includes: Drafts, Junk, Trash and Sent. These folders will be created at the user’s home directory. After you save and close all above config files, restart Dovecot.
sudo systemctl restart dovecot
Dovecot will be listening on port 143 (IMAP) and 993 (IMAPS), as can be seen with:
sudo ss -lnpt | grep dovecot
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.
systemctl status dovecot
We also need to restart Postfix to allow the LOGIN authentication mechanism.
sudo systemctl restart postfix
Using Dovecot to Deliver Email to Message Store
By default, Postfix uses its builtin local delivery agent (LDA) to move inbound emails to the message store (inbox, sent, trash, Junk, etc). We can configure it to use Dovecot to deliver emails, via the LMTP protocol, which is a simplified version of SMTP. LMTP allows for a highly scalable and reliable mail system. This step is required if you want to use the sieve plugin to filter inbound messages to different folders.
Install the Dovecot LMTP Server.
sudo apt install dovecot-lmtpd
Edit the Dovecot main configuration file.
sudo nano /etc/dovecot/dovecot.conf
Add lmtp
to the supported protocols.
protocols = imap lmtp
Save and close the file. Then edit the Dovecot 10-master.conf file.
sudo nano /etc/dovecot/conf.d/10-master.conf
Change the lmtp
service definition to the following.
service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { mode = 0600 user = postfix group = postfix } }
Next, edit the Postfix main configuration file.
sudo nano /etc/postfix/main.cf
Add the following lines at the end of the file. The first line tells Postfix to deliver 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.
mailbox_transport = lmtp:unix:private/dovecot-lmtp smtputf8_enable = no
Save and close the file. Finally, restart Postfix and Dovecot.
sudo systemctl restart postfix dovecot
Configure Desktop Email Client
Now open up your desktop email client such as Mozilla Thunderbird and add a mail account.
- In the incoming server section, select IMAP protocol, enter
mail.your-domain.com
as the server name, choose port 143 and STARTTLS. Choosenormal password
as the authentication method. - In the outgoing section, select SMTP protocol, enter
mail.your-domain.com
as the server name, choose port 587 and STARTTLS. Choosenormal password
as the authentication method.
Hint: 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 part 1. For example, if you have a user called user1
on your Ubuntu server, then you have an email address: [email protected]
, and the password for the email address is the same password for the user1
user. To create a local Unix account, run
sudo adduser user1
Note: Dovecot doesn’t allow you to login with the root
account. You need to create separate user accounts.
You can list all available mailbox users with:
sudo doveadm user '*'
It’s recommended to restart Dovecot after adding users, so Dovecot can recognize new mailbox users.
sudo systemctl restart dovecot
Troubleshooting Tips
As a rule of thumb, you should always check the mail log (/var/log/mail.log
) on your mail server when an error happens. The following is a list of specific errors and troubleshooting tips.
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.
sudo nmap mail.your-domain.com
And check if Dovecot is running.
systemctl status dovecot
You can also check the mail log (/var/log/mail.log
), which may give you some clues. If Dovecot fails to start, the error might not be logged to the /var/log/mail.log
file, you can run the following command to see what’s wrong.
sudo journalctl -eu dovecot
For example, some folks may have the following error in the journal.
doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/10-master.conf line 78: Unknown setting
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.
Cloudflare DNS
As I said in part 1, if you use Cloudflare DNS service, you should not enable the CDN (proxy) feature when creating DNS A record and AAAA record for the hostname of your mail server. Cloudflare doesn’t support SMTP or IMAP proxy.
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, Microsoft Outlook, etc) to submit outgoing emails. Port 25 should be used for SMTP server to SMTP server communications.
If you see the following “relay access denied” error in the /var/log/mail.log
file when trying to send emails from other mail services like Gmail to your own mail server, it’s likely that yourdomain.com
is not in the list of $mydestination
parameter.
NOQUEUE: reject: RCPT from mail-il1-f180.google.com[209.85.166.180]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-il1-f180.google.com>
You can display the current value of $mydestination
with:
postconf mydestination
Some folks might not have the main domain name in the list like so:
mydestination = $myhostname, localhost.$mydomain, localhost
Then run the following command to add the main domain name to the list.
sudo postconf -e "mydestination = yourdomain.com, \$myhostname, localhost.\$mydomain, localhost"
Reload Postfix for the changes to take effect.
sudo systemctl reload postfix
iOS Mail App
If you use the iOS Mail app to log into your mail server and encounter the following error.
You can try to fix it by enforcing SSL encryption, for both SMTP and IMAP.
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.
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 (
/var/log/mail.log
) to find out if there are other errors in your Postfix and Dovecot configuration.
You can use the Network Tools Email Checker to test if your SMTP server is reachable from the Internet. Just enter your domain email address and click the Go
button. As you can see from the screenshot below, it successfully found my domain’s MX record and my SMTP server is reachable from the Internet.
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 (/var/log/mail.log
) to find out if there is any errors in your Postfix and Dovecot configuration.
Auto-Renew TLS Certificate
You can create Cron job to automatically renew TLS certificate. Simply open root user’s crontab file.
sudo crontab -e
If you use Apache web server, add the following line at the bottom of the file.
@daily certbot renew --quiet && systemctl reload postfix dovecot apache2
If you are using Nginx web server, then add the following line.
@daily certbot renew --quiet && systemctl reload postfix dovecot nginx
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.
sudo systemctl restart dovecot
Instead of manually typing this command, we can make Dovecot automatically restart by editing the dovecot.service
systemd service unit. To override the default systemd service configuration, we create a separate directory.
sudo mkdir -p /etc/systemd/system/dovecot.service.d/
Then create a file under this directory.
sudo nano /etc/systemd/system/dovecot.service.d/restart.conf
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.
sudo systemctl daemon-reload
To check if this would work, kill Dovecot with:
sudo pkill dovecot
Then check Dovecot status. You will find Dovecot automatically restarted.
systemctl status dovecot
Next Step
I hope this article helped you set up Postfix and Dovecot on Ubuntu server. In part 3, I will show you how to create virtual mailboxes.
- Part 3: PostfixAdmin – Create Virtual Mailboxes on Ubuntu Mail Server (Ubuntu 18.04)
- Part 3: PostfixAdmin – Create Virtual Mailboxes on Ubuntu Mail Server (Ubuntu 20.04)
As always, if you found this post useful, subscribe to our newsletter to get more tips and tricks. Take care 🙂
Finally, a tutorial that tells everything that’s needed, not only parts of it. And finally, after about 12 hours of trying, I have a working email-server. So THANKS a lot!
I m looking for a reliable source which helps me to setup mail server (Ubuntu 19.10)
This seems better I will try with this….
Looking for suggestions from all friends
Thanks
This is THE best postfix/dovecot tutorial on the web. Thank you very much for posting. You covered a lot of material in great detail, but there are still a few parts that I’m unclear on.
When adding your mail account to your mail client, how do you know what the password is? We didn’t set a password for SMTP authentication in the walkthrough. If my Ubuntu user account is ‘admin’, and my email is [email protected], do I just use my local ‘admin’ account password to connect my mail client to my new email account?
What if, in my specific case, my local Ubuntu login is ‘admin’, but I want the email address “[email protected]” to be the default for all incoming and outgoing mail? Do I need to create a “user1” local user account on Ubuntu? I’ve send some test emails from the “[email protected]” account and the SPF/DKIM checks are failing. DKIM only passes the check when I send mail from my “[email protected]” account.
Well, I continued working at it and I answered one of my questions. Yes, each email account has to have a local user account on the Ubuntu server in order to have email. I have successfully added my accounts on my Android email application. Still looking into the other issue about the “[email protected]” failing DKIM (and therefore getting detected as spam).
So after some research and trial/error since my last post, I’m still having problems with DKIM. When I email the port25.com test system from the user account that I followed this guide from, I get a pass on everything. When I email from another user on the system and get a report form port25.com, everything except DKIM passes.
If I send mail from my root account, DKIM passes. I just can’t figure out what it is about this specific user account that’s causing it to fail. And of course, it happens to be the account that I primarily want to use to send and receive mail. Without DKIM passing, I’ve noticed that Google sends my messages straight to the spam box.
Aha! I figured out why my single user account was failing DKIM, and I understand why:
DKIM takes the message content and hashes it with the private key, then puts this in the email header. I was using an additional postfix configuration option called smtp_generic_maps to “rewrite” how my sender address would appear in the recipients inbox. DKIM did not like this modification and that is what was causing the DKIM check to fail on messages from this specific user. Hopefully this helps somebody else!
Simply comment out the smtp_generic_maps parameter in your /etc/postfix/main.cf file if you’re having this problem.
Thanks again for the wonderful guide!
After doing this part, I can send email but cannot receive email. Can you help me? 🙁
SOLVED!! I made a little mistake, sorry
This is the best guide for mail servers (for me now), THANKS YOU
I’ve got same hiccup: using email client I can send but cannot receive any email. I have followed exactly the steps in this tutorial. Would you share how you solve the problem? Thanks.
Don’t bother. Everything is fine now. Gmail was slow. Thanks.
Great tutorial, worked perfectly, thanks!
Hello,
In the command:
sudo certbot –nginx –agree-tos –redirect –hsts –email your-email-address -d mail.your-domain.com
What is the “your-email-address” I should provide ?
Kind regards,
Daniel
Your email address 🙂 ([email protected]). It’s used to receive important notifications about your certificate.
Hello,
My domain is not a .com one, it is a .co.uk (let’s say test.co.uk)
How should I replace “your-domain” in:
“sudo nano /etc/nginx/conf.d/mail.your-domain.com.conf” ?
Kind regards,
Daniel
You can run this command.
Hello Xiao,
Thank you very much for the guide, all works for me.
Also, thank you for the support !!!
Kind regards,
Daniel Orkan
Once again. Well done. Got everything working perfectly. I couldn’t find the “buy me a beer” link, but thanks for a very thorough job. Have you done an article on virtual mailboxes yet?
Yes, you can create virtual mailbox with Postfixadmin.
You can support this site on this page 🙂
I cannot thank you enough.
Beautifully written article.
Glad to know it’s working for you 🙂
Biiiiig thank you, Xiao!!!
before “sudo certbot –apache –agree-tos –redirect –hsts –email your-email-address -d mail.your-domain.com”
need to do “sudo apt-get update && sudo apt-get dist-upgrade”, cause some certbot python packages need to be upgraded. You got the error, while otbain certificates, if you dont upgrade some packages. Sorry for bad english.
You absolute boss.
I’ve rarely found a tutorial which just works.. for something so complicated and head spinning as well.
Kudos mate, really.
I can’t seem to receive any external mail (ie: from gmail) – but everything else seems to be working well. Any thoughts?
found the solution – just needed to run this:
WRONG PORT LISTED ABOVE:
still 5 star rating! very precise and plain in language and logic writing!! Thank you very much!!!
Question – When opening the ports, why not just do ufw allow dovecot?
First, there’s no “dovecot” UFW profile.
The profiles installed by the
dovecot
package are “Dovecot IMAP” and “Dovecot Secure IMAP”, which correspond to port 143 and port 993 respectively. They allow mail clients to fetch emails from the mail server.But you also need to open port 587 and 465 for mail clients to submit emails. And if you use webmail, open port 80 and 443.
You can run the following command to display available UFW profiles.
Then you can use the command below to check which port a profile allows, like
Output
Hi,
This tutorial is really good but I have a little problem with SMTP. I have configured the server in Thunderbird and the IMAP works perfect, but when I’m going to send emails, it says me something like this “Your connection has expired with the SMTP server”.
I can send messages with the
command perfectly, so I don’t know where is the problem. If you know any solutions, please let me know it.
Thank you in advance!
Is now working, thanks for the tutorial!
Hi,
My mail server works fine, as far as I know, after following your first three tutorials. Thank again! However, I don’t know how to make use of the letsencrypt setup. Can you provide some hint, or will you consider (maybe you already have?) writing a tutorial about this?
To learn how to use Let’s Encrypt (Certbot) on Ubuntu, visit the following links.
Apache version: Properly Enable HTTPS on Apache with Let’s Encrypt on Ubuntu
Nginx version: Properly Enable HTTPS on Nginx with Let’s Encrypt on Ubuntu
It´s works when I try whith a gmail account, but when I try send a email to a icloud account, that´s not receiving… can you help me please?
Hi, it´s me again,
firstly thanks for your super complete tutorial, that´s help me a lot 😀
the problem:
I ´m in black list of icloud…..
in mail.log i see this:
… refused to talk to me: 550 5.7.0 Blocked…
How can I solve this? help me :/
Read the Postmaster information for icloud mail. Basically you need to send an email to the icloud postmaster team to ask for removal of your IP address from the blacklist.
Thanks for your support 😀 I´m gonna try that.
Superb tutorial and perfect in all aspects!
I think I made a mistake when installing postfix and for system mail name I entered: mail.mydomain.com rather than mydomain.com and now the emails are @mail.mydomain.com rather @mydomain.com.
Anything that can fix the issue?
Thanks a lot
Edit /etc/mailname file and change mail.yourdomain.com to yourdomain.com. Then restart Postfix.
Thanks for the guide!
Trying to run the clean junk folders gives me an error. Any idea?
[email protected]:/home$ sudo doveadm expunge -A mailbox Trash all
doveadm(nobody): Error: User initialization failed: Namespace ”: mkdir(/nonexistent/mail) failed: Permission denied (euid=65534(nobody) egid=65534(nogroup))
doveadm(nobody): Error: User init failed
[email protected]:/home$ sudo doveadm user ‘*’
nobody
ubuntu
According to
man doveadm-expunge
, if the -A option is present, the command will be performed for all users, including thenobody
user. Since the nobody user’s home directory is /nonexistent/, an error would occur because the nobody user can’t create the /nonexistent/ directory.You can ignore this error by redirecting the error to /dev/null. A better approach would be getting the user list from a file. You can list users with:
Then you can use
sed
to delete the line containing the word “nobody” and save the result into a text file.Now we can use doveadm-expunge.
Note that if you use virtual mailbox domain as described in part 3, there would be no such error, because the user list is obtained from MySQL/MariaDB database.
Thank you so much for helping me understand!
First of all thank you for your documentation(s), it was really helpful for us!
After all we have a little problem. We created a same virtual user like the unix user eg: [email protected], and unix user is user1. It feels like its mixing the SMTP auth or something.
We can get the incoming emails, but we cannot send, because it’s asking SMTP pass, which perfectly fine. (We can login into roundcube.) Other virtual users works perfectly fine, but not the matching users.
Setup was built on your flow, so we using lemp, postfix, dovecot, postfixadmin and roundcube.
Could you give us tip where to start debugging our problem?
Thank you in advance!
I don’t think you can have a domain on Postfix that’s both a canonical domain (with Unix system account) and a virtual domain (with virtual users stored in MySQL/MariaDB database) at the same time.
Domains listed in
mydestination
parameter are canonical domains. If a domain is listed in thevirtual_mailbox_domains
parameter, then you can not list the domain inmydestination
parameter, as is described in Postfix documentation: NEVER list a virtual MAILBOX domain name as a mydestination domain!A virtual domain can’t have email addresses for Unix system accounts.
Thank you for your fast response.
Now i understand much clearly. If mydestination is mail.mydomain.com and virtual_mailbox_domains is mydomain.com, then i can have [email protected] mailbox independently from my Unix system account which is user1.
Could not be a problem to use the same “user” name, because the Unix system account will use the mydestination domain, right?
Yes. That’s correct.
Your help lead me to find out the problem.
When we want to use indentical username eg: user1 for unix system account and for mailbox account, then we should define the full username ([email protected]) in the email client to incoming/outgoing username.
Other virtual users can use simple username like presented on tutorial picture in document.
Thanks for all✌😁
The username for Unix system account doesn’t have a domain name.
The username for virtual domain user includes the domain part, as you can see by logging into MySQL/MariaDB database server and displaying the mailbox table in the postfixadmin database.
I’m not sure if your finding is correct. I think the username field in Thunberbird is misleading.
Thanx for the guide!
I can receive but I cannot send? Any clue what may cause it?
From mail log:
As per this guide I have in my master.cf file:
So do not have idea why this fatal error is there … or maybe it is not that?
Any help would be apreciated …
There should be no space after the comma.
Works like a charm!
Thank you!
Hello there,
At this stage I can received but when try to send it always says: Timeout when setting up SSL/TLS.
The log file of the mail client shows:
11:24:28 C: STARTTLS
11:24:28 S: 454 4.7.0 TLS not available due to local problem
11:24:28 Error: Unexpected return code 454 (expected 220):
“4.7.0 TLS not available due to local problem”.
11:24:28 Error code: 2001
11:24:28 Failed action (0). Reset observed read/write timeouts: 8/8
Can someone help with?
It’s likely that you have made a typo or something in the Postfix configuration file.
Hello Xiao & Thank You so much,
– You was right, I just redone the typing and it is now working but did not found where; I am now on way to part 3.
– Also on getting the Letsencrypt certificates you must disable the default virtual host of apache2 – “sudo a2dissite *default” – before enable your own. Otherwise it will fail every time you try to get the certificates.
—
Kindest Regards.
Disabling the default virtual host is not a must, if you have correctly configured the mail.yourdomain.com virtual host. I have obtained numerous TLS certificates without disabling the default virtual host.
Hello there,
on “Obtaining TLS Certificate with Nginx Web Server” the syntax of
the “~” is followed by a SPACE or by the SLASH ?
It’s a space. The
~
in Nginx is a regular expression. It’s not the Linux~
(home directory).In the file “/etc/nginx/conf.d/mail.your-domain.com.conf”,
the line “root /var/www/mail.your-domain.com/;” move the nginx server from “Welcome to nginx!” to “403 Forbidden”,
meaning when the line is comment with “#” the server answer with “Welcome to nginx!” and when the line is uncomment the server answer with “403 Forbidden”.
Any clue why?
This is not important in part 2. Follow my Roundcube tutorial to install a webmail client, then you will be able to login from webmail client at https://mail.your-domain.com.
Hello Xiao,
I follow this ‘IT Security Guidelines for Transport Layer Security
(TLS)’ from NCSC-NL, guideline B2-1 to B2-4 and table 2, 4, 6 and 7 (in
English) witch is considered here one of the best guides to cyber
security.
The website is :
[https://english.ncsc.nl/publications/publications/2019/juni/01/it-security-guidelines-for-transport-layer-security-tls]
The test tool is : “internet.nl”
About my installation they say on Ciphers (Algorithm selections) this:
Is there any way to unused phased out Ciphers?
—
Kindest Regards,
Alex
You can add the following lines in Postfix main configuration file to improve the security of TLS connection.
However, don’t be obsessed with TLS for SMTP and IMAP servers. If you are too strict about TLS, then there will be SMTP clients that can’t establish TLS connection with your SMTP server.
Hi i am having currently problem with the setting up my account via Thunderbird for start. I went three times over all three tutorials but something is always not working, i think i am maybe wonky with my fingers or whatever. But here we go, third time is the charm. So, at the moment i am at this stage(2nd).
And when i am trying to connect via Thunderbird, what password should i use?
Because we never created that during first 2 tutorials.
Should i use password that i am using to connect via terminal?
The first two parts use local Unix accounts as email addresses. For example, if you have a user called
dejan
on your Ubuntu server, then you have an email address: [email protected]main.com, and the password for the email address is the same password for thedejan
user.Thank you, i managed to login via THunderbird, but at the moment i am getting this error(in var/logs) dovecot: imap(contact): Error: Failed to autocreate mailbox Trash: Permission denied
Not sure what could be cause of this problem
please note that (at this date: 28/03/2020) in my machine: ubuntu 18.04.3 , the file: /etc/dovecot/conf.d/10-master.conf had the ports commented out, this resulted in the ports being “closed” when scanned from the outside
Other tan that, great job, I cant say wether all of this is needed to set it up in a “simple” way but anyway thanks 🙂
Hi Xiao,
I have another issues with the Thunderbird setup account:
I checked all the Q&A above in the thread and I understand that the [email protected] as the UNIX root and password. Do you have any solutions? How do I create a second: [email protected] to check it? Thanks so much.
To create another email address, simply create another Unix user account on your Ubuntu server.
Part 3 will show you how to create virtual users.
Hello,
Loving my setup… Thanks – I have followed all the way through (all 8ish parts).
I have run into one Challenge post setup, and this is confusing me.
Firstly… worth noting – Your setup is working!!!
It is working for all devices apart from an OLD Samsung Tab 2 failed the setup.
I have put this current challenge on this page as I think it could be the TLS SSL min protocols being part of the problem. But I don’t really want to tinker as I don’t know why you suggested these protocols. – Any suggestions as to what could be causing 1 old device to not work.
The device also doesn’t allow STARTTLS , so tried every option and none worked.
Also – feature request – PUSH messages, I would like to use this account for messages but the 15 mins or so i have to wait for IOS messages feels like an eternity . I have been searching and it appears you have to pay for Apple notification service? Feels bonkers!
Thank you!
I had to use this command to get past 404 errors with certbot
certbot certonly –agree-tos –expand –authenticator webroot –installer apache -d mail.domain.org –webroot-path /var/www/mail.domain.org/
Having a problem here. I’ve run the Postfix instructions in Part 2, but when I check systemctl status postfix it says postfix is “active (exited). Does this mean Postfix isn’t running? What have I done wrong?
This is normal, because the Postfix systemd service is a
oneshot
service. Postfix will run the master process after the main Postfix exits. If you run the following command, you can verify if Postfix master process if running.Output:
As you can see, the Postfix master process is listening on port 587, 465 and 25 on my mail server.
The dovecot systemd service is a
simple
service, so you will see “active(running)” instead of “active(exited)”.That’s not what I get. I don’t see 587 or 465 listed when I run the above command. Any ideas?
Found the problem! I had missed an underline character in /etc/postfix/main.cf. Once I fixed that and reloaded Postfix, everything fell into place.
Hello Xiao,
mail client connects, i can send mail. have recieved mail waiting to be collected by mail client
mail.log shows client connecting:
Not sure which side to start looking to solve this, do u have an idea?
Disabled the steps done in lmtp setup for now, imap works.
LMTP is required if your want to follow part 3 of this tutorial series.
I understand that, but my client doesnt seem to be able to collect my mail if its activated, ihave no idea why atm… what file/directory is it missing? and earlier i added lmtp behind imap as set protocols. but imap doesnt work if lmtp is there? or is there another issue?
I have already postfix installed as a sendonly SMTP server using your other guide. I want to be able to also send from desktop client. Do I need to install dovecot to be able to communicate with Postfix? If so, are there other steps I can omit from this guide when I don’t need to receive email?
Why do you want to manually send emails from a desktop email client, but don’t want to receive reply email from the recipient?
The reply goes to another email server (Gmail). I can’t send mail from that server.
That’s not a good practice.
Hmm really? So my wordpress server is sending out emails. Sometimes I need to write a custom email.
Another server is taking care of incoming mail.
Do you mean that you send only postfix server guide shouldn’t be combined with an external mail server for incoming and other email?
I can also send mail from the other server, but not in this case (my colleague is in China, where gmail is blocked so can’t send out email).
Thanks.
I mean if you send an email from your own domain, but the reply email goes to a free third-party email service like gmail, that will trigger some spam filters. Why not receive reply emails on your own domain?
I do receive emails to my own domains. GSuite (gmail) is setup for incoming mail to mydomain.com. The wordpress server is not connected to Gsuite and sending with Postfix. I though from your-send only Postfix guide that this was a ok setup?
Ok. I understand now. Simply follow the instructions in this article and you will be able to use desktop email client. Note that
inet_interfaces
should be set toall
in the/etc/postfix/main.cf
file.Thanks, so you mean I do need dovecot even when I will not receive mail?
Mozilla Thunderbird, and also other mail clients I think, will not allow you to log into your mail server or send emails if there’s no IMAP/POP3 server running.
Ok, I see. I thought the separate settings in thunderbird etc for smtp server was connecting directly to postfix, but I guess that’s also dovecot than.
Hi Xiao, thank you for the awesome guide!
I keep to fail at the last step (configuring Thunderbird). It always shows error box that IMAP server doesn’t allow choosen authentication method.
I checked nmap for srv.kulibaba.site and it seems that all necessary ports are open.
Also dovecot is running fine:
In the log part you can see the error I get.
When I created let’s encrypt certificate for srv.kulibaba.site I also added –must-staple option, that’s probably the only thing I did “against” your guide…
I also tried to tweak Thunderbird changing general.useragent.compatMode.firefox to True, though it didn’t help. Neither choosing oAuth2 as auth method helped. My next concern is ssl = required in 10-ssl.conf, but at this point I decided to refer to the source, making this comment.
Btw, initially if my hostname and MX record is srv.kulibaba.site, was it right to create virtual nginx host and issue certificate using this name instead of “mail.kulibaba.site”?
Seems like I managed to resolve the issue by setting:
security.ssl.enable_ocsp_must_staple = false
in Thunderbird config editor
Postfix and Dovecot don’t support OCSP stapling. If you add
--must-staple
to your TLS certificate, then mail clients (Thunderbird) would refuse to connect. I didn’t test it, but other SMTP servers are probably not able to establish secure TLS connection with your Postfix SMTP server.So I recommend obtaining a new TLS certificate for your hostname (srv.kulibaba.site) without using
--must-staple
.On ubuntu 20.04LTS “ssl_min_protocol = TLSv1.3” is not supported and we need to upgrade to at least dovecot 2.8
Can you help with ?
The latest stable version of Dovecot is 2.3.
Don’t be obsessed with using the latest cutting-edge TLS settings. That’s why you get TLS errors in your mail log. TLSv1.2 is secure enough.
Hi Xiao, at the beginning of the guide you wrote: “You need to have an Nginx virtual host for mail.your-domain.com before obtaining Let’s Encrypt TLS certificate”.
This is probably not true, I just need the certificate and see no reason in creating root folder and granting access to www-data. So I used certbot “certonly” option and configured nginx to make MX url forbidden (return 403). It seems to work fine. Do you see any problem with that?
Creating a virtual host is not a must if you have a default Nginx virtual host. There’s no problem with your method. However, you need to create a dedicated Nginx virtual host if you want to install Roundcube webmail later.
On Obtaining TLS Certificate with Nginx Web Server for ubuntu 20.04LTS I get the following error:
“AttributeError: module ‘acme.challenges’ has no attribute ‘TLSSNI01′”
Any clue on how to resolve this?
If you see the following error while trying to obtain TLS certificate on Ubuntu 20.04
You need to edit a config file.
Change
to:
Save and close the file. Then run the certbot command again to obtain TLS certificate.
Hello Xiao,
thank you for your very good tutorial. I successfully installed an email server using it. All good, but one point.
We have an ERP application which should send emails, but I cannot connect it to my email server. Not sure if I a missing some options of if I am inputing somethin wrong.
So I have:
outgoing mail server: mail.mydomain.com
port: 25
encryption: TLS
error: could not connect to SMTP host.
I tested with SMTP authentication (just took one created email address, not sure if I need another SMTP account..), I also tried without authentication.
Can you please give some insight?
Thank you!
You should use port 587.
Tahnk you.
Using port 587 I am a step closer. Same error if trying to connect to mail.domain.com but working if connecting to internal server IP.
Tested without SMTP auth (this is correct)?
New error on test email:
Mailer Error: Language string failed to load: tls The following From address failed: [email protected] Called Mail() without being connected
Can you please help with this error?
Thank you!
You should enable SMTP auth (enter an email address and password) on port 587.
really very nice and awesome tut! thanks for ur work
im trying to install mailserver for only local use, i have my own local dns server (bind9) and have mx record and stuff for my mail server, obv i cant use Let’s Encrypt, so im using openssl instead, followed to this part, i think everything’s fine
i can login using thunderbird in my laptop fine, it auto detect my settings, i try to send test email to myself (or another local account), i see the mail in sent folders but i receive nothing in inbox.
i see this in the /var/log/mail.log
i dont know where im going wrong, help is much appreciated!
thanks!
for some reasons i see the reply is posted “4 seconds ago” and it been days lol
anyway, solved my problem thanks!
Thanks for this tutorial!
Getting the following:
Of course, [email protected] isn’t the real address.
I created user1 with:
I can sign in with IMAP, but can’t send to it. Thoughts? Thanks!
What’s the output of this command:
Thanks!
I disabled the LMTP stuff and now it’s working okay. I don’t need virtual mailboxes so I’m good. Thanks so much!
Hi, thanks for the great tutorial!
What if Postfix and dovecot are running on separate servers like smtp.example.com and imap.example.com? How to configure LMTP?
Edit the Dovecot 10-master.conf file.
When Postfix and Dovecot are running on separte servers, you need to make LMTP service listen on TCP socket. Change the lmtp service definition to the following.
LMTP should be used in a local LAN and not be visible to the Internet, so you should use a private IP address for the
inet_listener
. Replace 10.10.10.2 with your own private IP address. If your SMTP server and IMAP server are not in the same LAN, you can use wireguard to create a virtual private network.Save and close the file. Then restart Dovecot.
Next, edit the Postfix main configuration file on the other server.
Add the following lines at the end of the file. The first line tells Postfix to deliver emails to local message store via the dovecot LMTP server listening on 10.10.10.2:2424. The second line disables SMTPUTF8 in Postfix, because Dovecot-LMTP doesn’t support this email extension.
Save and close the file. restart Postfix.
outbox/drafts etc not creating automatically:
When i set the 15-mailboxes.conf to create boxes automatically, then create a user with “sudo adduser user1” and then add it to thunder bird thunderbird only contains the inbox and nothing else (which confuses it when it tries to save sent mails to outbox etc)
“`
mailbox Junk {
auto = create
special_use = \Junk
}
mailbox Trash {
auto = create
special_use = \Trash
}
# For \Sent mailboxes there are two widely used names. We’ll mark both of
# them as \Sent. User typically deletes one of them if duplicates are created.
mailbox Sent {
auto = create
special_use = \Sent
}
mailbox “Sent Messages” {
special_use = \Sent
}
“`
The “Sent” folder will be automatically created when you send the first email. The “Trash” folder will be automatically created when you delete an email, etc.
Huge thanks for creating and maintaining this guide!
Everything is working happily for me… except the Microsoft Mail App (on Windows 10) which, no mater what I’ve tried, proclaims “Untrusted certificate”.
The cert is configured in /etc/dovecot/conf.d/10-ssl.conf
Another client I’ve tried (GMail on Android) doesn’t complain about the cert.
I’ve configured the MS Mail App to use mail. names for the incoming and outgoing servers and used the suggested ports of 143 and 587 (which default to imap.:993 for incoming and smtpauths.:25 for outgoing)
I almost wonder if despite the settings it’s still expecting to see imap. and smtpauths. listed in the cert or some other stupidity… it really gives me no detailed error information to go on.
I’ve sworn at it repeatedly and cursed windows 10 many times
I can ignore the “untrusted certificate” warning and everything appears happy – of course then once the cert gets renewed the windows mail app just silently stops syncing because the force-accepted cert no longer matches the retrieved cert and i have to remove the account(s), re-add them, and ignore the untrusted cert issue again because MS.
At this point I don’t think the problem is on the linux postfix/dovecot side, HOWEVER, I did experience my gmail client silently stop syncing too – until today when i was fiddling with my linux configs again when the gmail app suddenly started syncing my mail again.
If I can’t get this figured out I guess I’ll have to setup a daily cron to flick an email at me as a canary and go through the remove/re-add account process when the daily mails stop due to the cert being refreshed… I’d really like to solve this problem correctly though and have confidence that I’m not missing important mails.
Thanks again! Sorry for getting long winded here.
Thank you so very much!
This is by far the most helpful tutorial about anything that I have ever read, for so many reasons.
Cheers!
Hey! Great article. I have one doubt. I have a client send me a mail on port 25(which I cannot change). After following the first part, the client was able to send the mail on 25 and I was able to receive it.
After the 2nd part postfix was not listening to port 25.
I found out that `smtp inet n – y – 1 postscreen` line was commented in master.cf. I uncommented it and now I see it listening to port 25, but when the client tried to send a mail, he get’s no response and the request is just pending. Any idea what could be missing?
If you want to enable Postscreen, please read this article: Enable and Configure Postscreen in Postfix to Block Spambots
If you cat the /etc/postfix/master.cf file and paste it here, I might be able to troubleshoot your problem.
Also check your mail log file (/var/log/mail.log), it might give you some clues.
Where does postfix (or dovecot) even store these emails please?
If you are using virtual mailbox (PostfixAdmin), the emails are stored in
/var/vmail/yourdomain.com/username
.If you are not using virtual mailbox, the emails are stored under
~/Maildir
(The Maildir subdirectory under each user’s home directory.)Much appreciated
im not using virtual mailbox. Is it “/root/Maildir/new”? “/root/Maildir” has no other loose files and its other subdirectories ae empty. Anyway if it is “/root/Maildir/new” I see there are files in there but nothing after the 13 (this month) but i have sent many emails why is this? how is this even working?
oh i see its in
/home/plefort/Maildir
One more question. When i add my custom email account to gmail it doesnt save my sent emails to the sent folder. any thoughts?
is it because its using pop conventions, and so doesnt care about server storage, and so wont save anything to the server?
I’m not sure what you mean by “add my custom email account to gmail”.
Hello,
First, thank you for the detailed tutorial on setting up an email server with Ubuntu!
I’ve also followed the RoundCube tutorial (And the Postfix tutorial)from you and setup everything properly, but there seems to be an obstacle that prevents me from using Roundcube.
Logging in to Roundcube works perfectly fine, but sending and receiving emails cannot be done.
When using my email to test the server, I get a “Mail Undeliverable” message with the following error:
So the mail server cannot receive email.
Sending email using the Roundcube does nothing. After I compose a test email and click send, Roundcube would keep loading with no progress until I get an error that says “Request timed out”
What can I do to resolve this? Any leads would be appreciated, thank you!
Looks like some information was omitted for some reason, here is the actual error message I get from trying to send an email to my mail server:
Okay so now I can receive emails in the server. There is a minor change that I need to do in
I had to modify this line to include %Ln
This fixed the issue of not being able to receive emails in the mail server. But the problem of sending emails still persists. The Roundcube just loads indefinitely until the request timed out.
If you encounter errors with Roundcube, you can check the error logs at
/var/log/apache2/roundcube_error.log
(if you are using Apache), or/var/log/nginx/roundcube.error
(if you are using Nginx.)Thank you for this guide! It’s been very thorough and helpful
Nevermind, the issue has been resolved. I checked /var/log/mail.log and found out where the issue is. There was a typo (my bad lol) in master.cf file. After I fixed that one typo, and restarted the service, Roundcube can send and receive emails without problem.
Hi, Xiao. Thank you for helpful tutorials so much!! And I can’t send & recieve mail until this stage. mail.log says
mail postfix/lmtp[3305]:: to=, relay=mail.example.com[private/dovecot-lmtp], delay=0.14, delays=0.09/0.01/0.02/0.02, dsn=5.1.1, status=bounced (host mail.example.com[private/dovecot-lmtp] said: 550 5.1.1 User doesn’t exist: [email protected]ample.com (in reply to RCPT TO command))
Any ideas? thanks
Perhaps your email address is in lower case, but you used upper case when you send the email. You can edit the
/etc/dovecot/conf.d/10-auth.conf
file and change the auth_username_format toSo dovecot would lowercase the username. Restart Dovecot.
Hello there,
After installing Dovecot on ubuntu 20.04LTS i found out that dovecot 2.3.7.2 does not work with SSL1.3. So I need to update Dovecot to at least the version 2.3.8 or to the stable version 2.4
Can you help with?
The latest stable version of Dovecot is 2.3.
Don’t be obsessed with using the latest cutting-edge TLS settings. That’s why you get TLS errors in your mail log. TLSv1.2 is secure enough.
I concur this is an AMAZING write-up, thank you. I have several gsuite accounts and am trying to migrate one over to my local MX. Like a few others, I’ve completed the setup, triple checked your instructions, confirmed that there are no postfix or dovecot errors, yet can only send messages, but not receive any. Now, if I send a message from the domain I migrated, [email protected] to [email protected] it appears in my inbox. If I send from [email protected] to [email protected] – it also WORKS, but if I send from [email protected] to [email protected] the message never arrives in my Inbox. (18.04, Dovecot v. 2.3.10.1)
Thank you.
If there are no errors in mail log (/var/log/mail.log) after sending emails from gmail to your domain address. It could be:
1.) Your MX record is wrong, or the MX hostname doesn’t have an IP address.
2.) Port 25 (inbound) is closed.
Awesome. Port 25 was the issue; I’m 100%. I appreciate the article and the prompt response.
Hello there,
my mail log have a lot of this
SSL_accept error from st43p00im-ztfb10063301.me.com[17.58.63.179]: -1
Jul 7 16:44:01 www postfix/smtpd[66273]: warning: TLS library problem: error:14209102:SSL routines:tls_early_post_process_client_hello:unsupported protocol:../ssl/statem/statem_srvr.c:1685
What can be this? On their side or on my side?
Thank You
Don’t be obsessed with using the latest cutting-edge TLS settings. That’s why you get TLS errors in your mail log.
One other thing, I saw this message in mail.log:
‘mail dovecot: config: Warning: please set ssl_dh= /etc/dovecot/dh.pem’
After executing the suggested command, I didn’t see that message again…
HTH and thanks for your work on this how-to 🙂
Last suggestion: I always found it complicated and error-prone to get a Letsencrypt certificate via the method you recommend (which is the method commonly adopted in how-to’s on the Web). Instead, I prefer to stop the Web server and use the following command, which works without hassle every time:
certbot certonly –standalone –preferred-challenges http -d example.com -d www.example.com
(obviously, you have to replace ‘example.com’ with your own domain.) Then I respond to the prompts for a mail address and permission to be contacted by EFF and restart the Web server. I prefer to do certificate renewals in the same way…
You have to stop your web server again when you renew TLS certificate. (every 90 days)
If it’s not working, you have done something wrong. If you paste the error message when obtaining TLS certificate, perhaps I can help.
I have my certificates, and they’re working fine… I think you missed the point of what I was saying… 😉
Personally, I find that ‘certbot certonly –standalone’ with the Web server temporarily shut down is a lot less hassle than being obliged to set up the vhosts first and satisfy all the constraints of using the nginx/apache2 plugins…
I am not sure what the issue is but the postfix server receives my emails and they get stuck in the deffered ques because lmtp connection is being refused. The above is the output of “mailq”. Please help!
after running sudo netstat -lntp | dovecot I am getting the following error message:
doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/10-ssl.conf line 14: ssl_cert: Can’t open file /etc/letsencrypt/live/mail.lobap.ca/fullchain.pem: Permission denied
Any suggestion on how to fix it, please.
The correct command is
Hi, hope to save me. Everything is perfect until this command UbuntuServer 20.04.
“sudo add-apt-repository ppa:certbot/certbot”
E: The repository ‘http://ppa.launchpad.net/certbot/certbot/ubuntu focal Release’ does not have a Release file.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
I can´t install TLS Certificate. the port 443 does not open “attach picture”
I opened the ports by firewall UFW and I call my isp and all port are open. can you help me?
Certbot doesn’t have a PPA for Ubuntu 20.04. Remove it with:
Install certbot from the default software repository.
Hello Guo an,
When I send an email to my gmail account, there is a red lock on gmail which means that my email is not encrypted. However, my TLS letsencrypt connection is working so I don’t know what the problem is. How do I get rid of the red lock?
Maybe you forgot to add the following lines in /etc/postfix/main.cf file?
Found the problem!
It turns out that my postfix had enabled a PIX workaround “disable esmtp” which for some reason downgraded the connection to a HELO connection to Google.
I had the following line in my mail.log file:
This problem was fixed when I added the following line in my main.cf file:
Absolutely great guide. Life-saver!
When I try this step:
I got error message like attach file, can you help me Xiao?
Add DNS A record for email.vanhussen.net
I’m getting the same error, even though I have created an A record in my dns
Can’t find the A record of your hostname on dnsmap.io: https://dnsmap.io/#A/mail.nerdcomputers.net
Ask you domain registrar to find out why the A record doesn’t propagate to the Internet.
My Ubuntu 20.04 did not allow incoming traffic, while I explicitly have given ufw allow 25
In postfix main.cf file, I changed inet_interfaces from 127.0.0.1 to 0.0.0.0
If I understand well, the postfix installation that preexisted on my rented server was looking only at localserver for email. Probably kind of a countermeasure to prevent newly installed servers from accepting-relaying smap if postfix is not properly configured…
Robert
Edit /etc/postfix/main.cf file and change the value of
inet_interfaces
toall
.Then restart Postfix.
Thanks ! This is indeed what I tried and it cured the issue.
Robert
I keep getting the following error when trying to obtain a TLS certificate. I definitely have an A record on my godaddy domain page that leads to the server IP address. Is there anything else that could be causing this?
I can’t find the A record for mail.josephngechu.online. https://dnsmap.io/#A/mail.josephngechu.online
Hello,
Great guide. I’m getting this error when installing the certbot certificate:
It didn’t show up on dnsmap.io so i contacted namecheap and they told me (for the A and AAAA records) to get rid of the domain in the host field so to only have it as “mail”. It showed up on dnsmap.io but then i got this error:
Your help fixing this would be much appreciated.
Can’t find your A or AAAA record on dnsmap.io.
Sorry i left it with the broken records to see the error message. It now gives me this error message when i run the certbot certificate. I checked the IPv4 and v6 I entered and they’re correct.
Domain: mail.lunitacrafts.com
Type: unauthorized
Detail: Invalid response from
http://mail.lunitacrafts.com/.well-known/acme-challenge/MNUHdMy9MMeKL8fe5KOEecoCDaLkUFDJMV_lESlhckc
[2607:5501:3000:1141::2]: “\n\n
Found
Not Found
\n<p"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
It seems a firewall is blocking http/https requests to your mail server.
You need to open the following TCP ports on your mail server.
Hello. I am having issues with getting incoming mail working. I keep getting the error below when a mail server tries to connect to me:
The file definitely exists with what look like the correct permissions:
And here is my config excerpt from dovecot’s 10-master.conf:
I am at a loss to what the problem could be. I am using Ubuntu 20.04 LTS.
It looks like you changed the
submission
service in the/etc/postfix/master.cf
file.Besides configuring dovecot’s mailbox, postfix also needs to be configured; which is missing in this tutorial:
sudo postconf -e “home_mailbox = Maildir/”
Unless you didn’t configure LMTP as told in this article.
The
home_mailbox
parameter is used by Postifx’slocal
delivery agent. After configuring LMTP, Postfix will not use its ownlocal
delivery agent, but pass incoming emails to Dovecot via LMTP protocol, which is effected by the following setting. Postfix doesn’t care which mailbox format you are going to use.Yes, thanks for the hint. I did miss the service lmtp configuration part. Thus, I ultimately ran into another issue, I just was able to solve. (dovecot-lmtp: No such file or directory) Thanks for the lesson! Your tutorial is great and our Email-SRV is up and running flawlessly. (A bit slow, but at least it works for now)
Hi Xiao,
I attempted to redo the setup from the start and I’m now stuck – after configuring thunderbird and trying to send an email – I’m getting the following error :
I’m assuming it is listening on port 587:
Your submission service on port 587 advertises STARTTLS. Always check the mail log (/var/log/mail.log) when something went wrong.
I’m getting some errors on the RSA keys, from the priv.key – i’ve checked that the file exists. I’m not sure how to interpret this –
It seems you didn’t correctly enter the path for your TLS private key in
/etc/postfix/main.cf
file. The path is not complete.yes, you’re correct there was an error with the path. I had a typo on privkey.pem
Thanks you for the excellent guide!
I’ve been successful with creating the relay according to your relevant guide (sent confirmed it using the “mail [email protected]”). I’ve also been successful in connecting via IMAP from a mail client (Mac Mail client).
However, when trying to use the SMTP via Mac Mail client, I’m unsuccessful. Why could this be?
Thank you so much, and please accept my small donation 🙂
Here are a failed log (from Mail client) and a success log (from mail “[email protected]” command):
It seems your Mac mail client is trying to connect to port 25 of the mail server when sending emails. You should configure the mail client to connect to port 587 or 465.
Thanks for the reply! Why shouldn’t the mail client connect with my server on port 25 (incoming)? If I understood you correctly, the client can connect with my server on 25, and my server will communicate with the world via relay (which it seems like it does successfully from the fact that “mail …” worked.
Port 25 is usually used for MTA to MTA communication. MTA stands for Mail Transfer Agent, aka SMTP server.
Your mail client is MUA (Mail User Agent). Port 587 and 465 are used for MUA to MTA communication.
Most residential ISPs block port 25. It doesn’t make sense for mail clients to use port 25 to submit outgoing emails.
Thanks. Understood. Interesting then that that was the default for the Mail client.
Switched to 587, and it worked!
Thanks 🙂
Hi Xiao,
First of all,thank you for sharing the experience in seting up a mail server.
I have through the Part 2 and followed every step to setup a mail server,while I test the server,the test account ([email protected],ubuntu is my Linux user)can not receive any email from any server,but can send a mail.The error messages are bellow(as the attachment):
And the mail.log snippet:
The status of Dovecot:
I have try to set the /etc/dovecot/conf.d/10-auth.conf file and change the auth_username_format to
auth_username_format = %Ln
but it’s still not work !
Could you help me to fix the issues?
Thanks a lot!
Run the following command to list all available mailboxes on your server.
I already set up Apache server using cloudflare origin certificate. do I still need another certificate for email? or Can I point to the same SSL cert i am using in Apache2 conf?
If your mail server hostname is
mail.example.com
and your current certificate coversmail.example.com
, then you can use the current certificate.Hello. Thank you for the tutorials, I am learning a lot and its nice to have solid independant resources to learn from.
I have ran into a problem that I can not find a solution for. I will try to get help at #dovecot, but perhaps it’s something to bring up here as well. I successfully installed postfix and dovecot, and got connected through thunderbid and again on spark through my iphone. I successfuly add postfixadmin and did not retest the email. I moved on to trying to install roundcube and got to the config test and failed. Upon trying to relog into thunderbird and spark I was unable to login. Then I noticed I was unable to send email from the command line using postfix. I worked for awhile trying to find a solution and decided to start over.
Eventually I decided to purge everything and try again, once I did postfix worked again in the command line, so I tried to jump ahead and test roundcube. Postfix went down again. I am back to a point where I can send from the terminal in postfix, and it appears dovecot is running correctly, but I am unable to login in from thunderbird and spark still. I ran journalctl -eu dovecot and the only oddity that I found is this…
dovecot[10422]: auth: passwd-file(*user*,*clientip*,): unknown user
*user* being my user name without the domain and *clientip* being my home ip address, as I am logged in through ssh.
Any thoughts would be greatly appreciated, thanks.
Run the following command to list all mailbox users on your server.
It seems you changed the
userdb
settings in the/etc/dovecot/conf.d/auth-system.conf.ext
file.This displayed my account in the vmail system, which is correctly configued. I had made no changes to the userdb setting in /etc/dovecot/conf.d/auth-system.conf.ext., the only variable uncommented is driver = passwd. I realize now that this issue belongs in a thread on part 3, so I will move it over there.
Something much larger is going on here and I have spent many hours pouring over this to understand it and express it just in case anyone else comes across my issues so they don’t have to waste their time. The problem has too many oddities for it to be a simple error in syntax, or missed variable… etc. I have poured over the first 3 tutorials top to bottom and front to back, I am pretty certain I have everything correctly.
When I configure the SMTP server on thunderbird I can use the server properly (port 587 with standard TLS OR 465 SSL) but in both cases when I send an e-mail to my gmail account, the e-mail is not encrypted (red lock icon). I believe it is because of the following:
Can you help me?
I should maybe have mentioned: 1. Thank you so much for the tutorial!!! 2. both SPF and DKIM pass when I send e-mails (from part 4 of the tutorial)
AND, as from the other comments, the following params are set:
My bad, I was missing the following in my /etc/postfix/main.cf:
I’m sorry for cluttering the comment section and again, grateful for the tutorial!!
How to migrate from mbox to maildir
If you previously use mbox mail format, now you want to migrate to maildir format, here’s how.
Edit
/etc/dovecot/conf.d/10-mail.conf
file.Go to the
namespace inbox {}
section, find the following line.Uncomment this line and specify separator for the inbox namespace.
Then set
Save and close the file. Restart Dovecot for the changes to take effect.
Stop Postfix so there won’t be any new emails coming in.
Then run the following command to convert mbox to maildir for a user. (Sometimes I found I need to manually type the command. If I copy and paste it in the terminal, sometimes it won’t won’t. I don’t know why.)
If you have created folder in your mailbox, they will be converted as well and stored as hidden files under
~/Maildir
.If you have followed part 3 to set up virtual mailbox, then you need to sync the Maildir for the virtual users. For example,
Then change the ownership to vmail user.
Now reload the webmail. If some folders don’t show anymore, don’t worry, they are still there. You just need to re-enable them in Roundcube webmail settings.
if you see this error this error
● dovecot.service – Dovecot IMAP/POP3 email server
Loaded: loaded (/lib/systemd/system/dovecot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2020-11-11 14:33:44 UTC; 6s ago
Docs: man:dovecot(1)
http://wiki2.dovecot.org/
Process: 13110 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
Process: 22093 ExecStart=/usr/sbin/dovecot -F (code=exited, status=89)
Main PID: 22093 (code=exited, status=89)
Nov 11 14:33:44 mail.deeglowempire.com systemd[1]: Started Dovecot IMAP/POP3 email server.
Nov 11 14:33:44 mail.deeglowempire.com dovecot[22093]: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/10-ssl.conf line 54: Unknown setting: ssl_min_protocol = TLSv1.2
Nov 11 14:33:44 mail.deeglowempire.com systemd[1]: dovecot.service: Main process exited, code=exited, status=89/n/a
Nov 11 14:33:44 mail.deeglowempire.com systemd[1]: dovecot.service: Failed with result ‘exit-code’.
OPEN /etc/dovecot/conf.d/10-ssl.conf
PLEASE COMMENT OUT THIS LINE
#ssl_min_protocol = TLSv1.2
Hi, I noticed that to connect my email account to Thunderbird I have to disable Cloudflare option for my domain. Do you know what can cause such a problem ? When trying to set up an email account in Thunderbird with Cloudflare enabled, the program does not detect the server settings…
You should not enable the CDN (proxy) feature when creating DNS A record and AAAA record for the hostname of your mail server. Cloudflare doesn’t support SMTP or IMAP proxy 🙂
Hi Xiao,
Thank you for the tutorials. I fallowed everything and the server is running but when I try to send mail it is not delivered, on the log is written:
Port 25 (outbound) is blocked.
https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu#port-25-outbound
Thank you very match Xiao. I spoke with my ISP and port 25 was open, but they were put connection restrictions on it. After they remove it, everything works. Thank you very match again!
Hi Xiao,
thank you very much for the comprehensive tutorial! Basically everything works and I can send and receive mails. However postfix keeps randomly shutting down. Sometimes when I try to send an email and sometimes just by itself. Do you have any clue why such a thing occurrs?
You can open the
/var/log/syslog
file to see if you can find any clue. Search for the word “kill” in this file.For example,
This indicates the server ran out of memory, so it killed the
mysqld
process.Thanks for the response. Actually it was the monit process that was killing it. I don’t know how it was configured but disabling fixed the problem
Hello Xiao, Love your tutorials. I’ve followed parts 1 and 2 for setting up postfix and dovecote on ubuntu 20.04 and able to connect and log into imaps, but cannot get ports 465 and 587 to listen. The result from netstat is:
and submission and smtps as in your instructions are followed in postfix master.cf
and dovecot.conf unix listener
Been over this for the past 2 weeks looking for errors in the logs and not information reported in mail.log and dovecote.log. You help will be very much a time saver.
Stop Postfix.
Do a health check.
Run it in the foreground.
The output might give you some clues.
Xiao,
from sudo postfix check
checked the makedefs.out
Could it be a permissions issue?
Xiao,
Problem solved. The file /etc/postfix/postfix-files was not created on the install (there was a directory instead named postfix-files.d). Created file by touch postfix-files and presto magic, ports 465 and 587 appeared. Thanks for your time.
Hi Xiao, always got the error when I try to send mail:
But when I restart my postfix:
I can send my email.
But after that, I get the error again “Unable to send email to [email protected]!”
This is my mail.log:
Can you help me? THANK YOU!
I don’t know why, but some folks have problems after installing Monit. Try disabling Monit.
I have try this sir:
But stil got the error, but when I try remove monit.
Now I can send message anytime. I don’t know why
I can send message anytime
Hello, I get an error when I’m trying to run the following command:
sudo doveadm user ‘*’
RESULT:
Error: auth-master: userdb list: User listing returned failure
Fatal: user listing failed
Any idea of what can I do to fix it?
Regards,
Hello
as I tried to log in in thunderbird, I had dovecot log like user=
I created a unix user and dovecot doesn’t sees it,
thunderbird says cant login wrong pass or username
Maybe you should reboot your server?
hello Xiao, thanks for quick answer
I restarted dovecot many times, dovecot lists mailusers only [email protected]
I created unix user info, it doesn’t list it
thunderbird says cant login to smtp server wrong user or pass
If you followed part 3, then you can no longer use Unix accounts as email addresses. You must create virtual users in PostfixAdmin.
I didn’t follow part 3 since I’m afraid it removes mysql db
I just wish one single mail user, it’s enough with single unix user
but can’t login, and mail.log doesn’t write anything about dovecot attempts, or last one was like user=<>
Then you probably have followed tutorials on other websites. Don’t mix up mail server tutorials from different websites.
If you don’t know where’s wrong, you can add the following line in the /etc/dovecot/dovecot.conf file,
then restart dovecot, so dovecot will produce debugging message in the /var/log/mail.log file.
ok, I can now login as I rebuilt it all
now gmail says as I try to send to gmail address
Make sure you have set PTR record for the IP address of your mail server. And follow part 4 to set up SFP and DKIM.
Hello,
why incoming mails from google for example are removed automatically?
log writes message delivered, but then log writes “removed”
It’s removed from the Postfix mail queue, not removed from the message store (Inbox).
Hello Xiao,
Thank you for the guide 🙂
I am stuck with Roundcube setup.
Can’t login:
Remote login error:
IMAP connect: NOT OK(Login failed for [email protected] against mail.dkboyz.dk from 192.168.1.1. Could not connect to ssl://mail.dkboyz.dk:993: Unknown reason)
Local error (from the ubuntu 20.4 server):
roundcube connection to storage server failed
I think that it’s a problem with Dovecot, because i get this when i run systemctl status dovecot:
I can’t seem to fix the problem.
Maybe you could lead me in the right direction?
Regards
Thomas
Dovecot can’t find your SSL certificate. Open the
/etc/dovecot/conf.d/10-ssl.conf
file, make sure you specify the correct location of your SSL certificate and private key.Is this wrong???
It’s from the /etc/dovecot/conf.d/10-ssl.conf file.
‘# SSL/TLS support: yes, no, required.
ssl = required
ssl_cert = </etc/letsencrypt/live/dkboyz.dk-0001/fullchain.pem
ssl_key = </etc/letsencrypt/live/dkboyz.dk-0001/privkey.pem
It seems your certificate files are corrupted. Renew your certificate.
Then restart Postfix and Dovecot.
Dovecot should use the certificate for
mail.dkboyz.dk
. The configuration should be:The certificate for
dkboyz.dk
is irrelevant.I am also getting this error. I have removed certbot and purged it. Deleted the letsencrypt directory and sub directories. Re-installed certbot and regenerate the certs. These are the paths in my file
ssl_cert = </etc/letsencrypt/live/mail.aheart4god.us/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.aheart4god.us/privkey.pem
I am able to cd into that directory copying the path from the line above.
I did a force renew and restarted the postfix and dovecot. Still getting the error No Valid PEM.
any ideas?
Could this be causing a problem?
LISTEN 0 0 *:587 *:* users:((“smtpd”,pid=2823,fd=6),(“master”,pid=2606,fd=16))
Hey Xiao,
Thanks for the guide, good job. I just wanted to let you know that if you have more host names, it is actually easier just to use the temporary server when doing the challenge. I needed it for 4 host names and did the following.
certbot certonly –cert-name babe.dk -d babe.dk -d mail.babe.dk -d www.babe.dk -d dea.dk -d mail.dea.dk -d www.dea.dk
How would you like to authenticate with the ACME CA?
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
1: Apache Web Server plugin (apache)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Select the appropriate number [1-3] then [enter] (press ‘c’ to cancel): 2
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/babe.dk/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/babe.dk/privkey.pem
Made my life a little easier 😉
/Christian
when i try to install certificate
sudo certbot certonly -a nginx –agree-tos –no-eff-email –staple-ocsp –email [email protected] -d mail.your-domain.com i got output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mail.mydomain.com
Waiting for verification…
Challenge failed for domain mail.mydomain.com
http-01 challenge for mail.mydomain.com
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
– The following errors were reported by the server:
Domain: mail.mydomain.com
Type: unauthorized
Detail: Invalid response from
http://mail.mydomain.com/.well-known/acme-challenge/xT1TZ3cDXxx-9pk_XAplZcoPf6uprT0mUsSHNMkU2eI
[119.15.81.237]: “\r\n
Found
404 Not
Found
\r\n
nginx/1.18.0 (Ub”
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
After upgrading to “20.10”, I can’t receive any mails with “Thunderbird”. I can only send out but with an error message that the message couldn’t be copied to the “sent”-folder. “Thunderbird” keeps telling me “[email protected]: Checking mail server capabilities…” in the status bar. “mail.err” has repeatedly this error message:
“Jan 21 00:43:58 test dovecot: imap-login: Error: Failed to initialize SSL server context: Can’t load DH parameters (ssl_dh setting): error:1408518A:SSL routines:ssl3_ctx_ctrl:dh key too small: user=, rip=192.168.1.1, lip=192.168.1.173, session=”
What does it mean and how can I repair my mail server?
i have a similar error, i’ve managed to send out emails, but Thunderbird told me “There was an error saving the message to Sent Messages. Retry?”. i could find incoming emails saved under /Maildir/cur, but no copy saved under /Maildir/.Sent for outgoing emails
Thank you for this, all working perfectly, I am a linux newbie, always used windows in the past, you have made me want to learn a lot more about linux : )
Hi Guoan,
somehow i can’t get my android (outlook client) to send email to my ubuntu configured with dovecot and postfix with smtp auth.
I assume dovecot is the one for performing smtp-auth(?)
can you post some example, such as doveconf -Pn for references?
i can send out fine (to gmail), I can send from gmail to the vps fine too.
thanks
want to supplement more information.
– i want to compose an email from android outlook and relay to my ubuntu (20.04) vps, setup with dovecot, postfix and postfixadmin vmail.
– i can actually send successful, when using gmail android client setup
– i cannot send successful when using the outlook android client setup.
could be something with microsoft …again.
do let me know anything can be shared to look into it.
thanks
As a rule of thumb, you should always check the mail log (/var/log/mail.log) on your mail server when an error happens.
Thank you for this;
i can send emails from my email client but i don’t receive emails sent to me. My log is attached below
If you can’t receive emails from Gmail, Hotmail, Yahoo Mail, etc, here are the possible causes:
/var/log/mail.log
) to find out if there are other errors in your Postfix and Dovecot configuration.You can use the Network Tools Email Checker to test if your SMTP server is reachable from the Internet. Just enter your domain email address and click the
Go
button. As you can see from the screenshot below, it successfully found my domain’s MX record and my SMTP server is reachable from the Internet.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 (
/var/log/mail.log
) to find out if there is any errors in your Postfix and Dovecot configuration.Your posted mail log is too short and I can’t work out a conclusion.
This is indeed one of the best, if not the only, step-by-step tutorial on making real-life email system. I having been trying to make this happen for 3 days with no fruitful results, until I read this series and followed it step by step.
Thank you a lot!