test
This commit is contained in:
@@ -30,6 +30,9 @@ 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}")
|
||||
@@ -44,7 +47,8 @@ class CustomSMTPServer(smtpd.SMTPServer):
|
||||
# 验证收件人域名
|
||||
valid_recipients = []
|
||||
for rcpt in rcpttos:
|
||||
if not rcpt.endswith('@nosqli.com'):
|
||||
is_valid = any(rcpt.endswith(f'@{domain}') for domain in self.ALLOWED_DOMAINS)
|
||||
if not is_valid:
|
||||
logger.warning(f"Rejected mail to {rcpt}: invalid domain")
|
||||
else:
|
||||
valid_recipients.append(rcpt)
|
||||
|
||||
Reference in New Issue
Block a user