s365b.core.mailview =================== .. py:module:: s365b.core.mailview .. autoapi-nested-parse:: Read a stored email (MIME) for display: headers, plain text, attachments. Used by the browse view. Nothing here renders HTML: an HTML body becomes text, so a backed-up message cannot run script or load remote images in the admin's browser. Attributes ---------- .. autoapisummary:: s365b.core.mailview.MAX_BODY Classes ------- .. autoapisummary:: s365b.core.mailview.MessageView Functions --------- .. autoapisummary:: s365b.core.mailview.html_to_text s365b.core.mailview.read_message Module Contents --------------- .. py:data:: MAX_BODY :value: 200000 .. py:function:: html_to_text(html: str) -> str Convert HTML to readable plain text. :param html: An HTML document or fragment. :returns: The visible text with paragraph breaks. .. py:class:: MessageView An email prepared for display. :ivar subject: Subject. :ivar sender: From. :ivar to: To. :ivar cc: Cc. :ivar date: Date header as sent. :ivar body: Plain-text body (HTML converted), possibly truncated. :ivar body_was_html: The body came from an HTML part. :ivar truncated: The body was cut at :data:`MAX_BODY` characters. :ivar attachments: ``{"filename", "content_type", "size"}`` per attachment. .. py:attribute:: subject :type: str :value: '' .. py:attribute:: sender :type: str :value: '' .. py:attribute:: to :type: str :value: '' .. py:attribute:: cc :type: str :value: '' .. py:attribute:: date :type: str :value: '' .. py:attribute:: body :type: str :value: '' .. py:attribute:: body_was_html :type: bool :value: False .. py:attribute:: truncated :type: bool :value: False .. py:attribute:: attachments :type: list[dict[str, Any]] :value: [] .. py:function:: read_message(raw: bytes) -> MessageView Parse a MIME message for display. :param raw: The message as stored (RFC 5322 / MIME). :returns: Headers, plain-text body and attachment list.