Why use both Dovecot and Postfix?

Solution 1:

Postfix and Dovecot do different things.

Postfix is an MTA, or Mail Transfer Agent. It accepts mail from the outside world and from local sources, and routes it to its destination. This may involve an smtp connection to another machine, or it may involve delivering it to a local delivery agent or writing it directly to an mbox. When an MTA goes wrong, things get ugly; your machine may be used to bounce huge amounts of spam, for instance. However, because of the way that our email system works, an MTA has to interact constantly with both legitimate and unwanted mail sources.

Dovecot is mailbox interface software. Specifically, it allows users to access their mailboxes using the IMAP interface. If configured correctly, it only interacts with authenticated users. This means that in general, dovecot doesn't have to "talk to the bad guys."

The view from 50,000 feet: Postfix "knows about" smtp. Dovecot "knows about" IMAP.

(Yes, postfix can use dovecot to perform authentication, and dovecot's lda to put mail in mboxes, so there's definitely more to the story.)