Skip to content
Ubuntu Linux

How to Install Dovecot on Ubuntu 24.04

Richard
Written by
Richard
Updated 5 min read
How to Install Dovecot on Ubuntu 24.04
How to Install Dovecot on Ubuntu 24.04

Dovecot is open-source mail server software for Ubuntu 24.04 LTS. It lets you host your own email and read it in desktop apps like Outlook or Thunderbird. It handles IMAP (Internet Message Access Protocol) and POP3 (Post Office Protocol), the standard rules mail apps use to download messages from a server. Postfix receives and sends the mail, and Dovecot hands it to your mail app.

Setting up Dovecot on Ubuntu 24.04 takes a few terminal commands and a handful of edits to its configuration files. It gives you full control over personal mailboxes without relying on a third-party hosting service. Once it is running, your email programs connect directly to your server to fetch incoming mail.

You need an account with sudo rights and a working internet connection. Every command and file edit below needs root privileges.

⚡ Quick Answer

Open a terminal on Ubuntu 24.04 and run sudo apt install dovecot-imapd dovecot-pop3d to install Dovecot as your IMAP and POP3 mail server. Postfix should already be installed and running first, since Dovecot serves the mail Postfix delivers. The install takes a minute or two, and you then edit /etc/dovecot/dovecot.conf and files in /etc/dovecot/conf.d/ to finish setup.

Advertisement

Install Dovecot

Installing Dovecot is a normal package install. Postfix should already be installed and running before you start, because Dovecot reads the mail that Postfix delivers. Installing the package takes a minute or two. Then you can move on to the configuration files.

  1. Open a terminal with Ctrl+Alt+T, or connect to the server over SSH.
  2. Check that Postfix is installed and active (see the next section).
  3. Run the install command shown further down.
📝Good to KnowThe Postfix mail server must be active before you continue with Dovecot. If your Ubuntu 24.04 system does not have Postfix yet, complete the setup in the guide linked below first. Dovecot installs without Postfix, but it has nothing to serve until a mail transfer agent is delivering mail.
Advertisement

How to install Postfix on Ubuntu

Once Postfix is ready, run the command below to install Dovecot.

  1. Paste the command into your terminal and press Enter.
  2. Enter your password if sudo asks for it. Nothing shows on screen as you type it.
  3. Confirm with Y if apt asks whether to continue. The package list scrolls by, and you return to the prompt when the install is done.

The main Dovecot configuration file is usually at /etc/dovecot/dovecot.conf. You need to change it after installing Dovecot on Ubuntu 24.04. These settings control how the server behaves, so the edits that follow tailor it to your network.

You will edit four files in total: the main file, then auth.conf, mail.conf and master.conf. In each one you either remove a leading # from a line (uncomment it) or change a single line. Edit them with root rights, for example by opening them with sudo and a text editor such as nano.

Start with the primary configuration file. Open it with the command below, uncomment the highlighted lines, and save the changes.

  1. Run the command to open the file in your editor.
🐧Bash / Shell
sudo nano /etc/dovecot/dovecot.conf
  1. Find the highlighted lines and delete the # at the start of each one. Leave the rest of the line as it is. Do not leave a space before the setting name.
💻Code
# A comma separated list of IPs or hosts where to listen in for connections. 
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.

listen = *, ::
  1. Save and exit. In nano, press Ctrl+O, then Enter to write the file, then Ctrl+X to close it.

Next, open the auth.conf file, uncomment the necessary lines, and save your changes. This file controls how Dovecot checks user logins.

  1. Run the command to open the file.
🐧Bash / Shell
sudo nano /etc/dovecot/conf.d/10-auth.conf
  1. Remove the # from the highlighted lines only. Leave every other commented line alone.
💻Code
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.

disable_plaintext_auth = no

# Space separated list of wanted authentication mechanisms:
# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp
# gss-spnego
# NOTE: See also disable_plaintext_auth setting.

auth_mechanisms = plain login
  1. Save and exit the file.
📝Good to KnowNext, open the mail.conf file, change the designated line, and save your work. This file tells Dovecot where and in what format your mailboxes are stored, so the value must match what Postfix uses.
  1. Run the command to open the file.
🐧Bash / Shell
sudo nano /etc/dovecot/conf.d/10-mail.conf
  1. Find the highlighted line and change it to the value shown in the code block that follows. Replace the old value and keep the setting name.
💻Code
#
# <doc/wiki/MailLocation.txt>

mail_location = maildir:~/Maildir
  1. Save and exit the file.

Next, open the master.conf file, locate lines 110 – 112, and uncomment the targeted block before saving. This block sets up the service that lets Postfix hand off authentication to Dovecot.

  1. Run the command to open the file.
🐧Bash / Shell
sudo nano  /etc/dovecot/conf.d/10-master.conf
  1. Go to lines 110 – 112. In nano, Ctrl + _ lets you jump to a line number. Remove the # from every line of the section shown below. Line numbers can shift slightly between package versions, so match the block by its content rather than by number alone.
💻Code
  # Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
  1. Save and exit the file.

Restart the service to apply the changes. Dovecot only reads its configuration files when it starts, so nothing you edited takes effect until you do this. No reboot of the server is needed.

If the restart prints an error, go back to the file you edited last. Look for a # you missed, a typo in a value, or a stray character at the start of a line. Fix it, save, and restart again.

🐧Bash / Shell
sudo systemctl restart dovecot

You now have a working mail server on your network. Review these core takeaways as you move forward:

Careful configuration keeps communication between Postfix, Dovecot and your mail apps stable. Most problems after a fresh install come from a missed uncomment or a mistyped value.

With Dovecot set up, your Ubuntu server can now store mail and serve it to your email apps.

  • Dovecot is a reliable open-source IMAP and POP3 email server that lets mail apps retrieve messages from your server.
  • It works well with popular mail delivery agents like Postfix or Exim.
  • The installation uses simple commands to get Dovecot running alongside Postfix. Install and test Postfix first.
  • Configuration files such as dovecot.conf, 10-auth.conf, 10-mail.conf, and 10-master.conf are essential for tailoring Dovecot to your specific needs.
  • Remember to restart Dovecot after making changes so the new settings apply.

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *