# Modmail

class `praw.models.reddit.subreddit.``Modmail`(subreddit)

  Provides modmail functions for a subreddit.

  `__call__`(id=None, mark_read=False)

    Return an individual conversation.

    Parameters:

    - id – A reddit base36 conversation ID, e.g., `2gmz`.
    - mark_read – If True, conversation is marked as read (default: False).

    Example:

        reddit.subreddit('redditdev').modmail('2gmz', mark_read=True)

    To print all messages from a conversation as Markdown source:

        conversation = reddit.subreddit('redditdev').modmail('2gmz', mark_read=True)
        for message in conversation.messages:
            print(message.body_markdown)

    `ModmailConversation.user` is a special instance of `Redditor` with extra attributes describing the non-moderator user’s recent posts, comments, and modmail messages within the subreddit, as well as information on active bans and mutes. This attribute does not exist on internal moderator discussions.

    For example, to print the user’s ban status:

        conversation = reddit.subreddit('redditdev').modmail('2gmz', mark_read=True)
        print(conversation.user.ban_status)

    To print a list of recent submissions by the user:

        conversation = reddit.subreddit('redditdev').modmail('2gmz', mark_read=True)
        print(conversation.user.recent_posts)

  `__init__`(subreddit)

    Construct an instance of the Modmail object.

  `bulk_read`(other_subreddits=None, state=None)

    Mark conversations for subreddit(s) as read.

    Due to server-side restrictions, ‘all’ is not a valid subreddit for this method. Instead, use `subreddits()` to get a list of subreddits using the new modmail.

    Parameters:

    - other_subreddits – A list of `Subreddit` instances for which to mark conversations (default: None).
    - state – Can be one of: all, archived, highlighted, inprogress, mod, new, notifications, (default: all). “all” does not include internal or archived conversations.

    Returns: | A list of `ModmailConversation` instances that were marked read.

    For example, to mark all notifications for a subreddit as read:

        subreddit = reddit.subreddit('redditdev')
        subreddit.modmail.bulk_read(state='notifications')

  `conversations`(after=None, limit=None, other_subreddits=None, sort=None, state=None)

    Generate `ModmailConversation` objects for subreddit(s).

    Parameters:

    - after – A base36 modmail conversation id. When provided, the listing begins after this conversation (default: None).
    - limit – The maximum number of conversations to fetch. If None, the server-side default is 25 at the time of writing (default: None).
    - other_subreddits – A list of `Subreddit` instances for which to fetch conversations (default: None).
    - sort – Can be one of: mod, recent, unread, user (default: recent).
    - state – Can be one of: all, archived, highlighted, inprogress, mod, new, notifications, (default: all). “all” does not include internal or archived conversations.

    Example:

        conversations = reddit.subreddit('all').modmail.conversations(state='mod')

  `create`(subject, body, recipient, author_hidden=False)

    Create a new modmail conversation.

    Parameters:

    - subject – The message subject. Cannot be empty.
    - body – The message body. Cannot be empty.
    - recipient – The recipient; a username or an instance of `Redditor`.
    - author_hidden – When True, author is hidden from non-moderators (default: False).

    Returns: | A `ModmailConversation` object for the newly created conversation.

        subreddit = reddit.subreddit('redditdev')
        redditor = reddit.redditor('bboe')
        subreddit.modmail.create('Subject', 'Body', redditor)

  `subreddits`()

    Yield subreddits using the new modmail that the user moderates.

    Example:

        subreddits = reddit.subreddit('all').modmail.subreddits()

  `unread_count`()

    Return unread conversation count by conversation state.

    At time of writing, possible states are: archived, highlighted, inprogress, mod, new, notifications.

    Returns: | A dict mapping conversation states to unread counts.

    For example, to print the count of unread moderator discussions:

        subreddit = reddit.subreddit('redditdev')
        unread_counts = subreddit.modmail.unread_count()
        print(unread_counts['mod'])