multipart/mixed content type and boundary refused by Amavis

Solution 1:

The issue was that the webclient we're using is expecting a correct Content-Type header for the attachment:

Content-Type: application/pdf; name="filename.pdf"

To figure out this, I looked at some emails I've received from the postfix server (/var/spool/imap/our_domain/...) and compared it to the raw email I'm producing with my script. The most noticeable difference was this header.