diff --git a/main.py b/main.py index 0fdd548..2df715f 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +# pylint: disable=C0301, C0114 import json import imaplib import smtplib @@ -5,22 +6,23 @@ import email from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.utils import parseaddr +from email.header import decode_header import time import datetime import logging -import socks import socket import re - -from email.header import decode_header +import socks def provider_in(address, provider_list): + """Check if the provider is in the provider list""" for provider in provider_list: if address.endswith(provider): return True return False def decode_mime_words(s): + """Decodes a string containing multiple MIME words""" decoded_fragments = decode_header(s) return ''.join( str(fragment, encoding or 'utf-8') if isinstance(fragment, bytes) else fragment @@ -28,30 +30,34 @@ def decode_mime_words(s): ) def add_mask(original_msg, content, is_html): + """Adds a mask to the content""" original_subject = decode_mime_words(original_msg['Subject']) from_name, from_address = parseaddr(original_msg['From']) from_name = decode_mime_words(from_name) to_name, to_address = parseaddr(original_msg['To']) to_name = decode_mime_words(to_name) header = f"""
Forwarded Email {'' if is_html else 'This email is plain text, it may have display issues '} | From: {from_name} <{from_address}> To: {to_name} <{to_address}> Subject: {original_subject} |
""" - footer = f""" |
FORWARDED | Notice: This is a automatically forwarded email, which means it may contains something bad. You shouldn't reply directly to this email, it will never reach your destination! |
FORWARDED | Notice: This is a automatically forwarded email, which means it may contains something bad. You shouldn't reply directly to this email, it will never reach your destination! |