This commit is contained in:
2026-01-25 13:20:58 -06:00
parent 3884abc695
commit 2d9aba7e04
37 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""
SES operations handler
"""
import boto3
from botocore.exceptions import ClientError
from logger import log
from config import config
class SESHandler:
"""Handles all SES operations"""
def __init__(self):
self.client = boto3.client('ses', region_name=config.aws_region)
def send_raw_email(
self,
source: str,
destination: str,
raw_message: bytes,
worker_name: str
) -> bool:
"""
Send raw email via SES
Args:
source: From address
destination: To address
raw_message: Raw MIME message bytes
worker_name: Worker name for logging
Returns:
True if sent successfully, False otherwise
"""
try:
self.client.send_raw_email(
Source=source,
Destinations=[destination],
RawMessage={'Data': raw_message}
)
return True
except ClientError as e:
error_code = e.response['Error']['Code']
log(f"⚠ SES send failed to {destination} ({error_code}): {e}", 'ERROR', worker_name)
return False
except Exception as e:
log(f"⚠ SES send failed to {destination}: {e}", 'ERROR', worker_name)
return False