This commit is contained in:
Andreas Knuth 2025-12-17 13:44:37 -06:00
parent c2288d22dc
commit e756c5f91d
1 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import signal
from email.parser import BytesParser
from email.policy import SMTP as SMTPPolicy
from datetime import datetime
from botocore.exceptions import ClientError # Neu: Korrekter Import für SES-Exceptions
# AWS Configuration
AWS_REGION = 'us-east-2'
@ -566,13 +567,16 @@ def process_message(message_body: dict, receive_count: int) -> bool:
)
log(f"✓ Forwarded to {forward_to} from {recipient} (original: {original_from})")
except boto3.exceptions.ClientError as e:
if 'MessageRejected' in str(e):
log(f"⚠ SES rejected: {e}. Check verification.", 'ERROR')
except ClientError as e: # Fix: Korrekter Exception-Typ
error_code = e.response['Error']['Code']
if error_code == 'MessageRejected':
log(f"⚠ SES rejected send for {recipient}: {e}. Check verification or quotas.", 'ERROR')
elif error_code == 'AccessDenied':
log(f"⚠ SES AccessDenied for {recipient}: {e}. Check IAM policy.", 'ERROR')
else:
log(f"⚠ Rules error for {recipient}: {e}", 'WARNING')
log(f"SES error for {recipient}: {e}", 'ERROR')
except Exception as e:
log(f"⚠ General error: {e}", 'WARNING')
log(f"⚠ General error for {recipient}: {e}", 'WARNING')
# 6. SMTP VERSAND (Loop über Recipients)
log(f"📤 Sending to {len(recipients)} recipient(s)...")