I know that I can choose different transport agents (different SMTP servers) for different mail accounts. However, how to deliver messages larger than 10 MB using local SMTP server and smaller messages using an external service (e.g. Google SMTP servers)?

Is there any message size based transport policies? How to edit them?

[more information]

The reason I want to do this since the external email provider I use for email delivery limits outgoing messages' size to a maximum of 10 MB each so I want to send those large messages using my own SMTP servers while all others using the external service.

  • 1
    Mind adding the problem you are trying to solve here to your question? What you propose is certainly achievable, but I wonder if the underlying problem has simpler solutions.
    – anx
    Commented Oct 8, 2020 at 19:27

1 Answer 1


One way is to use the ClamAV milter. Scan outbound messages in the usual way, e.g.

smtpd_milters = unix:/var/run/clamav/clamav-milter
milter_default_action = accept

In the milter config, set

MaxFileSize 10M
AddHeader Replace

If the milter rejects the message, processing continues. But the X-Virus headers will be different. You can then use this header, e.g. in header_checks, for postfix to route accordingly.

Not entirely within postfix, so someone else might have a cleaner answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .