'Escape CR and LF characters, and limit length.
RFC 2822\'s hard limit is 998 characters per line. So, minus "Subject: "
the actual subject must be no longer than 989 characters.'

def format_subject(self, subject):

    formatted_subject = subject.replace('\n', '\\n').replace('\r', '\\r')
    return formatted_subject[:989]
