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] => 188.8.131.52 [client_name] => smtprelay0179.hostedemail.com [client_port] => 59713 [reverse_client_name] => smtprelay0179.hostedemail.com [helo_name] => smtprelay.hostedemail.com [sender] => firstname.lastname@example.org [recipient] => email@example.com [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?
master.cf I have configured my script like this:
filtermyemail unix - n n - 0 spawn user=someuser argv=php /path-to-scripts/filter-incoming-email.php