You might want to look into email-spec https://github.com/bmabey/email-spec