[CentOS] Story of an email

Tue Dec 3 18:46:42 UTC 2013
Mike Burger <mburger at bubbanfriends.org>

> Mike Burger wrote:
>
>>>>> I'm running postfix + dovecot on my CentOS server,
>>>>> together with amavisd, clamd and spamassassin,
>>>>> following the instructions in
>>>>> <http://wiki.centos.org/HowTos/postfix>.
>>>>> As far as I can see it is all working,
>>>>> but I must admit I'm not clear exactly what path
>>>>> an incoming email travels along.
>>>>> I asked this question before, and someone suggested
>>>>> a document I should read,
>>>>> but unfortunately I've mislaid the note I made at the time.
>
>> Assuming that you've properly configured the master.cf and main.cf to
>> allow amavisd/clamav scanning of email, the following is how the process
>> will flow:
>>
>> Remote mail client (user, some other mail server, etc) connects to port
>> 25
>> to send an email through your Postfix installation.
>>
>> Postfix passes the email to amavisd over some port.
>>
>> Amavisd processes the email through clamav and, if the message is clean,
>> passes it back to Postfix through a different port.
>>
>> Postfix delivers the message (to a remote mail server, or to a local
>> user).
>
> Thanks for your response.
> I've a couple of queries.
>
> 1) Where does SpamAssassin come into the process?
>
> 2) In my case all incoming email comes through fetchmail
> from external mail servers like gmail.
> I take it that this is sent through port 25 to postfix,
> more precisely to the sendmail emulator of postfix?
>
> 3) I take it that in the last stage postfix passes the email to dovecot,
> which stores it in ~/Maildir/cur/ (in my case).
>
> It is picked up from there by KMail on my laptop,
> but that is another story.

1) Usually via procmail, called in /etc/procmailrc. On my system, that
file contains:

USER=`whoami`

:0 fw
| spamc

:0 e
{
        EXITCODE=$?
}

2) Fetchmail is, effectively, a mail client, and connects to Gmail via
IMAP or POP3. Without seeing the fetchmail configuration (I've never had
to make use of it), I'll have to assume that fetchmail does pass the mail
through to Postfix over port 25.

To clarify on the second part of this question, there's no "sendmail
emulator" in play, though...Postfix is a replacement for Sendmail, with
all the requisite functionality built in without having to resort to some
sort of emulation.

3) Postfix makes use of the procmail agent to deliver the email to the
mail spools in /var/spool/mail and/or, if the user has procmail recipes in
place to do any type of sorting/archival, mail spool files usually in
$HOMEDIR/mail. Dovecot then queries those mailstores (POP3 will only query
the inbox in /var/spool/mail, IMAP will query all of the other folders as
long as your mail client requests it to do so).