Implement changes discussed in #1821
Cherry-picked 4e54cabc5147e3b9e21d640627fd13a0bd3750c2
Made some changes to respect the old logic of the setAttachments method
Make sure all changes from 4e54cabc5147e3b9e21d640627fd13a0bd3750c2 were brought back
Merge pull request #1863 from DeuxHuitHuit/fix-1821

Implement email attachment encoding charset. Closes #1821