I am updating a mailer from Python2. There I used the line
attachFile.set_payload(file(attachment[1]).read())
How can I create the same effec