Accessing mail body on postfix check_policy_service event

TheStoryCoder asked:

I followed postfix documentation to set up a script that I can use to write custom filters on incoming mail on the check_policy_service event and it works just fine, but I cannot access the email body – only the following parameters from STDIN:

Array
(
    [request] => smtpd_access_policy
    [protocol_state] => RCPT
    [protocol_name] => ESMTP
    [client_address] => 208.40.44.179
    [client_name] => smtprelay0179.hostedemail.com
    [client_port] => 59713
    [reverse_client_name] => smtprelay0179.hostedemail.com
    [helo_name] => smtprelay.hostedemail.com
    [sender] => [email protected]
    [recipient] => [email protected]
    [recipient_count] => 0
    [queue_id] => 
    [instance] => 27c5.5bccec9c.5f5b9.0
    [size] => 1905
    [etrn_domain] => 
    [stress] => 
    [sasl_method] => 
    [sasl_username] => 
    [sasl_sender] => 
    [ccert_subject] => 
    [ccert_issuer] => 
    [ccert_fingerprint] => 
    [ccert_pubkey_fingerprint] => 
    [encryption_protocol] => TLSv1.2
    [encryption_cipher] => AECDH-AES256-SHA
    [encryption_keysize] => 256
    [policy_context] => 
)

How can I access the raw email (headers and body) so that my filtering can optionally depend on that as well?

My answer:


Access policy delegation doesn’t transmit the message body. You’ll need to create a milter instead, if you need access to the message body.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.