reids 动态thinkadmin后台增加域名
This commit is contained in:
10
app/utils.py
10
app/utils.py
@@ -30,24 +30,22 @@ class CustomSMTPServer(smtpd.SMTPServer):
|
||||
logger.info(f"Initializing SMTP server on {localaddr}")
|
||||
super().__init__(localaddr, remoteaddr)
|
||||
|
||||
# 定义允许的域名列表
|
||||
ALLOWED_DOMAINS = ['nosqli.com', 'email.nosqli.com']
|
||||
|
||||
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
|
||||
try:
|
||||
logger.debug(f"Connection from peer: {peer}")
|
||||
logger.debug(f"Mail from: {mailfrom}")
|
||||
logger.debug(f"Recipients: {rcpttos}")
|
||||
logger.debug(f"Raw data length: {len(data)} bytes")
|
||||
logger.debug(f"Additional kwargs: {kwargs}") # 记录额外的参数
|
||||
logger.debug(f"Additional kwargs: {kwargs}")
|
||||
|
||||
# 记录接收到的邮件基本信息
|
||||
logger.info(f"Received mail from {mailfrom} to {rcpttos}")
|
||||
|
||||
# 验证收件人域名
|
||||
# 从 Redis 获取允许的域名
|
||||
allowed_domains = get_allowed_domains()
|
||||
valid_recipients = []
|
||||
for rcpt in rcpttos:
|
||||
is_valid = any(rcpt.endswith(f'@{domain}') for domain in self.ALLOWED_DOMAINS)
|
||||
is_valid = any(rcpt.endswith(f'@{domain}') for domain in allowed_domains)
|
||||
if not is_valid:
|
||||
logger.warning(f"Rejected mail to {rcpt}: invalid domain")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user