Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Mail Services»How to Install Dovecot on Ubuntu 20.04

    How to Install Dovecot on Ubuntu 20.04

    By RahulJuly 22, 20213 Mins Read

    Dovecot is an open-source service for IMAP and POP3 on Unix-like operating systems. It focused on lightweight and secure mail servers available for most of the Linux operating systems.

    Advertisement

    POP3 (Post Office Protocol 3) and IMAP (Internet Message Access Protocol) both are protocols works as message accessing agent. These protocols are used to fetch email messages from user inboxes on mail servers. In simple words, POP3 and IMAP are responsible to fetch messages from mailboxes and show them on your mobile device or web interface.

    This tutorial will help you to install and configure the Dovecot service on Ubuntu 20.04 system.

    Prerequisites

    • A running Ubuntu 20.04 system
    • Pre-configured mail server and user Mailboxes
    • Shell access with root or sudo privileged account

    Step 1 – Install Dovecot on Ubuntu

    Debian-based systems have separate packages of Dovecot for IMAP and POP3 protocols. To install Dovecot server with the POP3 and IMAP functions support, run the following command:

    sudo apt install dovecot-imapd dovecot-pop3d
    

    You can also install various Dovecot modules like MySQL and PostgreSQL database support, mail filtering, full-text search, spam filter training, and LDAP directory. To install additional modules run:

    sudo apt install dovecot-sieve dovecot-solr dovecot-antispam
    

    Step 2 – Dovecot Configuration

    Once the installation is finished, configure the Dovecot server as per your requirements. Here is the quick and useful configuration of Dovecot to work on your system.

    1. Enable Protocols: By default Dovecot has enabled POP3 and IMAP protocols in main configuration file. You can edit main configuration file and see:
      sudo nano /etc/dovecot/dovecot.conf
      
      !include_try /usr/share/dovecot/protocols.d/*.protocol
      
    2. Listen Interface: By default Dovecot listen on all interfaces including IPV6. But if you need to restrict them to specific interface edit:
      sudo nano /etc/dovecot/dovecot.conf
      
      listen = *, ::
      

      Change “*” with the interface IP like “192.168.1.10”

    3. Authentication: Then edit the authentication file for Dovecot and update following values.
      sudo nano /etc/dovecot/conf.d/10-auth.conf
      
      disable_plaintext_auth = no
      auth_mechanisms = plain login
      
    4. Setup Mailbox Directory: After that, edit mail configuration file to configure location of the Mailbox. Make sure to set this to correct location where your email server is configure to save users emails.
      sudo nano /etc/dovecot/conf.d/10-mail.conf
      
      mail_location = maildir:~/Maildir
      
    5. Setup User: Next, edit below configuration file and set the username and group name of the mail server is running with.
      sudo nano /etc/dovecot/conf.d/10-master.conf
      
        unix_listener /var/spool/postfix/private/auth {
          mode = 0666
          user = postfix
          group = postfix
        }
      
    6. Setup SSL: It is an good idea to enable SSL for the Dovecot. Edit file and set SSL to yes or required. By default it uses self singed certificate, if you have your own certificates update them as followings.
      sudo nano /etc/dovecot/conf.d/10-ssl.conf
      
      ssl = yes
      
      ssl_cert = 

    Step 3 - Manage Dovecot Service

    We can manage dovecot using the systemctl command-line tool. Use the following command to enable the Dovecot service.

    sudo systemctl enable dovecot.service
    

    Use the following commands to start/stop or restart Dovecot service:

    sudo systemctl start dovecot.service
    sudo systemctl stop dovecot.service
    

    Use the below command to view the current status of the service

    sudo systemctl status dovecot.service
    

    Step 4 - Test Configuration

    To test this setup, I have created an account with name "rahul" on Ubuntu system. The mbox setting on Postfix server is configured to ~/Maildir directory.

    Next, you need a mutt command-line utility to connect the mailbox using IMAP protocol.

    sudo apt install mutt
    

    Then connect to mailbox using below command:

    mutt -f imaps://[email protected]
    

    This will prompt to accept certificate (Press a for accept always). After that, it will prompt for the password. Enter user password and press enter. You will see the emails of your account.

    Mutt IMAPs Connection

    Step 5 - Open Ports with FirewallD

    For the systems running with firewalld need to allow following ports to allow access from network. Below is the list of port used by the POP3 and IMAP protocols:

    • IMAP - 143
    • IMAPS - 993
    • POP3 - 110
    • POP3S - 995

    To add the firewall rules, execute the following commands:

    sudo firewall-cmd --add-service={pop3,imap} --permanent
    sudo firewall-cmd --add-service={pop3s,imaps} --permanent
    

    Then reload the changes.

    sudo firewall-cmd --reload
    

    Conclusion

    In this tutorial, you have learned to install and configure the Dovecot server on the Ubuntu system. You have configured your server to access the user mailbox via POP3 or IMAP protocols.

    dovecot IMAP POP3
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Postfix: Relay Email from SMTP based on From Address

    Postfix: Relay Outgoing Emails Based On Sender Address

    How to Setup DKIM (DomainKeys) with Postfix

    A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

    Installing Roundcube on Ubuntu

    How to Install Roundcube Webmail on Ubuntu 20.04

    View 1 Comment

    1 Comment

    1. Dan on September 27, 2022 4:20 pm

      What’s this code all about

      unix_listener /var/spool/postfix/private/auth {
      mode = 0666
      user = postfix
      group = postfix
      }

      and why is there an error thrown at the mode line ?

      There’s no explanation at all of how to put email for each Postfix address into separate mailboxes and then connect to each mailbox from a local mail client like Outlook or Thunderbird.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.