On 2025-05-06 at 12:58:27 UTC-0400 (Tue, 6 May 2025 19:58:27 +0300)
Mike Teplynin via Postfix-users <m.teply...@gmail.com>
is rumored to have said:
After my previous question about mail archiving, I tried to write a
milter that will save copies of emails in a way convenient for me.
And now my question is about how Postfix sends headers and message
body to milter. Everything that is sent after the DATA command is
buffer somewhere and passed to milter only after <CRLF>.<CRLF>?
No.
The headers and body are passed to the Milter seperately and possibly in
multiple "chunks."
The best simple overview of how it works that I'm aware of is at
https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/milter-protocol.md#data-smfic_data-smtp-data
Sadly, there has never been robust definitive docs for the Milter API.
This is why I always recommend that people use a pre-built Milter like
MIMEDefang or MailMunge which handle all the arcane details for you and
let you just act like you get a whole message after the end-of-DATA
'<CRLF><CRLF>'
Maybe I'm doing something wrong, or using a bad language/library
(python/pymilter), but in my application I can work with headers and
body only after <CRLF>.<CRLF>,
That's fine, because that's the only time you HAVE the body and headers.
while I can process information about
connect/helo/mail_from/rcpt_tо immediately.
This is why the Milter API has distinct calls for each step in the SMTP
protocol.
For example, if connection is interrupted during the message transfer,
I can save info about helo, the sender and recipient addresses, but
not the part of the message that the client managed to send (because
the milter did not receive it?)
Correct. An interrupted transfer that is not completed by the SMTP
client with a terminating <CRLF>.<CRLF> is likely to be retried later by
that sending client. Based on my experience I do not believe that
Postfix ever sends "chunks" of the body unless the whole thing has been
received, but I could be wrong or that may be a Postfix-only behavior
that a milter program can't universally rely upon. I've never seen any
indication of the Milter I use most (MIMEDefang) receiving a piece of a
message which ultimately aborted.
--
Bill Cole
b...@scconsult.com or billc...@apache.org
(AKA @grumpybozo@toad.social and many *@billmail.scconsult.com
addresses)
Not Currently Available For Hire
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org