<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_content(self, content, mime_type=None):
 """Add content to the email :param contents: Content to be added to the email :type contents: Content :param mime_type: Override the mime type :type mime_type: MimeType, str """

        if isinstance(content, str):
            content = Content(mime_type, content)
        # Content of mime type text/plain must always come first
        if content.mime_type == "text/plain":
            self._contents = self._ensure_insert(content, self._contents)
        else:
            if self._contents:
                index = len(self._contents)
            else:
                index = 0
            self._contents = self._ensure_append(
                content, self._contents, index=index)