Question

How to setup dovecot and postfix

Hello, I know, there are many articles on this, but for me they miss the simplest things. 1)I just want to setup a dovecot server on some linux machine that holds email for local accounts in Maildirformat and provides them to user-mail-software like evolution locally. 2)I want postfix to send mail locally to dovecot. 3)I want to use fetchmail to pick up mail from my internet provider via pop3 and use postfix to distribute it locally. No mention of sending out mail so far. Except for 3) I don’t want to be bothered by SSL, PAM, LTS … it’s all local.

I pretty much have 1) running. I can connect to dovecot and access my localy stored mail via IMAP.

But I can’t get the communication between postfix and dovecot to work. Do I need virtual-domain, virtual-users to be able to send to dovecot or just local stuff in my use-case. Do I use lda or lmtp? How does the mapping from local mail-addresses to user-accounts (and thus mail-dirs) work. Does postfix do this or dovecot? Currently postfix apparently sends the full email like karl@fritz.box to dovecot and dovecot refuses.

I am kind of lost.

Wolfgang

P.S.: I had all of this running in the past. Postfix put the mail in /var/spool/mail/… and dovecot used that as INBOX. Apprently dovecot cannot read mbox-INBOX files anymore if it is configured to store as maildir. It’s one or the other now.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
April 22, 2023

Heya @wolfgangbuesser,

It seems like you’re on the right track. I’ll try to address your questions and provide you with a simple guide to achieve your desired setup.

  1. You mentioned that you already have Dovecot running and can access your locally stored email via IMAP. That’s great! Let’s move on to the next step.

  2. To make Postfix send mail locally to Dovecot, you need to configure Postfix to use Dovecot’s LMTP (Local Mail Transfer Protocol) service. LMTP is more efficient than LDA (Local Delivery Agent) and is the recommended method for Dovecot. Here’s a simple configuration to achieve this:

  • Configure Postfix to use Dovecot’s LMTP service. Edit the /etc/postfix/main.cf file and add the following lines:
  1. mailbox_transport = lmtp:unix:private/dovecot-lmtp
  • Edit the Dovecot configuration file, usually located at /etc/dovecot/dovecot.conf or /etc/dovecot/conf.d/10-mail.conf, and set the mail location:
  1. mail_location = maildir:~/Maildir
  • Enable and configure the LMTP service in Dovecot. Edit the file /etc/dovecot/conf.d/10-lmtp.conf:
  1. service lmtp {
  2. unix_listener /var/spool/postfix/private/dovecot-lmtp {
  3. mode = 0600
  4. user = postfix
  5. group = postfix
  6. }
  7. protocol lmtp {
  8. postmaster_address = postmaster@yourdomain.com
  9. hostname = yourdomain.com
  10. }
  11. }
  1. For fetchmail to pick up mail from your internet provider via POP3 and use Postfix to distribute it locally, you’ll need to configure fetchmail. Create a configuration file, for example, ~/.fetchmailrc:
  1. poll your.provider.com protocol POP3
  2. user "your_username@provider.com" password "your_password"
  3. is "local_username" here
  4. fetchall
  5. no ssl

Replace the placeholders with the appropriate values for your provider and local username. Then, run fetchmail in the background:

fetchmail -d 300

This will make fetchmail run as a daemon, checking for new mail every 5 minutes (300 seconds).

With these configurations, you should be able to achieve the setup you described. Let me know if you have any questions or need further assistance.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel