Search code examples
mimeemail-headersmime-message

What are the valid characters for a Mime Multipart message ContentId "CID:"?


From reading the RFC it appears that CID can/must only contain characters from the same set as those permissable by a regular URI. Is this correct. Im asking because I wish to writeup a simple helper that takes a CIDs prefix and adds a counter when generating CID for mime multitypes attachments.


Solution

  • The Content-ID value is required to be in the form of an RFC-822 addr-spec (user@domain).

    Since an addr-spec may contain characters not allowed in a URL, those characters are hex-encoded when used in the "cid" URL.

    Per RFC2392:

    A "cid" URL is converted to the corresponding Content-ID message header [MIME] by
    removing the "cid:" prefix, converting the % encoded character to their equivalent US-ASCII characters, and enclosing the remaining parts with an angle bracket pair, "<" and ">".

    Read more: http://www.faqs.org/rfcs/rfc2392.html