need to set content id for attachments to be able to embed images using cid method also the line 373 should be changed to: for key, value in attachment.headers.items(): need the .items():