Yes, p3scan is designed to run in a network gateway. The typical dovecot (mail-server) service runs in another host, but it does not matter.
Here the involved protocol is not IMAP, but POP3. POP3 clients in LAN connects remote POP3 servers; p3scan in the middle intercepts POP3 traffic and scan messages for viruses. It also add spam headers, but only clamd here decides what is blocked and what can pass.