I need to take an arbitrary string and make it safe to use as part of an email address, replacing characters if necessary. This is to submit text to an API that requires values to be encoded into the address the email is being sent to. However, this is fraught with pitfalls and I'd like to make sure that whatever is input isn't going to break mail delivery. I'm already planning on just double-quoting the entire local part, which is going to mitigate a lot of the issues.
I've found a guide to what characters can be used in the local part of an email address, but it seems to make no distinction between 'It's forbidden by the RFCs' and 'It can be confusing so it's best to stay away' and 'it can only be used when escaped properly'. Does anyone have a reference to something clearer/faster to read than the appropriate RFCs themselves?
Edit: I have no control over the parsing on the receiving end nor can I change how the text gets submitted as something other than a straight ASCII string.