message in english
This commit is contained in:
parent
b3f84e91a8
commit
c8bb77886a
|
|
@ -1,31 +1,31 @@
|
|||
#!/bin/bash
|
||||
# test_migration_email.sh - Stellt eine Test-EMail in S3 + SQS ein
|
||||
# test_migration_email.sh - Places a test email into S3 + SQS
|
||||
#
|
||||
# Simuliert den kompletten SES-Eingang: Mail landet in S3, Metadaten in SQS.
|
||||
# Der Worker holt sie dann ab und verarbeitet sie (Delivery oder Forward).
|
||||
# Simulates the complete SES inbound flow: Mail goes to S3, metadata to SQS.
|
||||
# The worker picks it up and processes it (Delivery or Forward).
|
||||
#
|
||||
# Verwendung:
|
||||
# Usage:
|
||||
# ./test_migration_email.sh cielectrical.com carlosr@cielectrical.com
|
||||
# ./test_migration_email.sh buddelectric.net service@buddelectric.net
|
||||
#
|
||||
# Optionale Absenderadresse:
|
||||
# ./test_migration_email.sh cielectrical.com carlosr@cielectrical.com test@example.com
|
||||
# Optional sender address:
|
||||
# ./test_migration_email.sh cielectrical.com carlosr@cielectrical.com sender@example.com
|
||||
|
||||
set -e
|
||||
|
||||
# --- Parameter ---
|
||||
# --- Parameters ---
|
||||
DOMAIN="$1"
|
||||
RECIPIENT="$2"
|
||||
FROM_ADDR="${3:-migration-test@andreasknuth.de}"
|
||||
AWS_REGION=${AWS_REGION:-"us-east-2"}
|
||||
|
||||
if [ -z "$DOMAIN" ] || [ -z "$RECIPIENT" ]; then
|
||||
echo "Verwendung: $0 <domain> <recipient> [from-address]"
|
||||
echo "Beispiel: $0 cielectrical.com carlosr@cielectrical.com"
|
||||
echo "Usage: $0 <domain> <recipient> [from-address]"
|
||||
echo "Example: $0 cielectrical.com carlosr@cielectrical.com"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Abgeleitete Variablen ---
|
||||
# --- Derived variables ---
|
||||
BUCKET_NAME=$(echo "$DOMAIN" | tr '.' '-')"-emails"
|
||||
QUEUE_NAME=$(echo "$DOMAIN" | tr '.' '-')"-queue"
|
||||
MESSAGE_ID="test-migration-$(date +%s)-$$"
|
||||
|
|
@ -33,58 +33,60 @@ TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|||
DATE_RFC2822=$(date -R)
|
||||
|
||||
echo "============================================================"
|
||||
echo " 📧 Test-Mail für Migration"
|
||||
echo " Migration Test Email"
|
||||
echo "============================================================"
|
||||
echo " Domain: $DOMAIN"
|
||||
echo " Empfänger: $RECIPIENT"
|
||||
echo " Absender: $FROM_ADDR"
|
||||
echo " Recipient: $RECIPIENT"
|
||||
echo " Sender: $FROM_ADDR"
|
||||
echo " Bucket: $BUCKET_NAME"
|
||||
echo " Queue: $QUEUE_NAME"
|
||||
echo " Key: $MESSAGE_ID"
|
||||
echo ""
|
||||
|
||||
# --- Schritt 1: E-Mail als RFC822 erstellen ---
|
||||
echo "[1/3] Erstelle Test-Email..."
|
||||
# --- Step 1: Create RFC822 email ---
|
||||
echo "[1/3] Creating test email..."
|
||||
|
||||
MAIL_CONTENT="From: Migration Test <${FROM_ADDR}>
|
||||
TMP_FILE=$(mktemp /tmp/test-mail-XXXXXX.eml)
|
||||
|
||||
cat > "$TMP_FILE" << EOF
|
||||
From: Migration Test <${FROM_ADDR}>
|
||||
To: ${RECIPIENT}
|
||||
Subject: Migration Test $(date '+%Y-%m-%d %H:%M:%S')
|
||||
Date: ${DATE_RFC2822}
|
||||
Message-ID: <${MESSAGE_ID}@test.email-srvr.com>
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
Hallo!
|
||||
Hello!
|
||||
|
||||
Dies ist eine Test-EMail zur Validierung der E-Mail-Migration.
|
||||
This is a test email to validate the email migration pipeline.
|
||||
|
||||
Gesendet: $(date)
|
||||
Sent: $(date)
|
||||
Domain: ${DOMAIN}
|
||||
Empfaenger: ${RECIPIENT}
|
||||
Recipient: ${RECIPIENT}
|
||||
Message-ID: ${MESSAGE_ID}
|
||||
|
||||
Wenn du diese Mail in deiner Inbox siehst, funktioniert der
|
||||
komplette Pfad: S3 -> SQS -> Worker -> Forward/Delivery.
|
||||
If you see this email in your inbox, the complete path is working:
|
||||
S3 -> SQS -> Worker -> Forward/Delivery
|
||||
|
||||
--
|
||||
Bay Area Affiliates Migration Test"
|
||||
Bay Area Affiliates - Migration Test
|
||||
EOF
|
||||
|
||||
TMP_FILE=$(mktemp /tmp/test-mail-XXXXXX.eml)
|
||||
echo "$MAIL_CONTENT" > "$TMP_FILE"
|
||||
echo " Done ($(wc -c < "$TMP_FILE") bytes)"
|
||||
|
||||
echo " ✓ Mail erstellt ($(wc -c < "$TMP_FILE") Bytes)"
|
||||
|
||||
# --- Schritt 2: In S3 Bucket ablegen ---
|
||||
echo "[2/3] Lade Mail in S3 hoch: s3://${BUCKET_NAME}/${MESSAGE_ID} ..."
|
||||
# --- Step 2: Upload to S3 ---
|
||||
echo "[2/3] Uploading to S3: s3://${BUCKET_NAME}/${MESSAGE_ID} ..."
|
||||
|
||||
aws s3 cp "$TMP_FILE" "s3://${BUCKET_NAME}/${MESSAGE_ID}" \
|
||||
--region "$AWS_REGION" \
|
||||
--quiet
|
||||
|
||||
echo " ✓ S3 Upload erfolgreich"
|
||||
echo " Done"
|
||||
|
||||
# --- Schritt 3: SQS Message im Fake-SNS-Format einstellen ---
|
||||
echo "[3/3] Stelle Message in SQS Queue..."
|
||||
# --- Step 3: Place SQS message in fake-SNS format ---
|
||||
echo "[3/3] Placing message in SQS queue..."
|
||||
|
||||
QUEUE_URL=$(aws sqs get-queue-url \
|
||||
--queue-name "$QUEUE_NAME" \
|
||||
|
|
@ -93,12 +95,12 @@ QUEUE_URL=$(aws sqs get-queue-url \
|
|||
--query 'QueueUrl')
|
||||
|
||||
if [ -z "$QUEUE_URL" ]; then
|
||||
echo " ❌ Queue $QUEUE_NAME nicht gefunden!"
|
||||
echo " ERROR: Queue $QUEUE_NAME not found!"
|
||||
rm -f "$TMP_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# SES Event Payload (das was die Lambda normalerweise erzeugt)
|
||||
# SES event payload (what the Lambda normally produces)
|
||||
SES_DATA=$(jq -n \
|
||||
--arg msgId "$MESSAGE_ID" \
|
||||
--arg source "$FROM_ADDR" \
|
||||
|
|
@ -122,7 +124,7 @@ SES_DATA=$(jq -n \
|
|||
}
|
||||
}')
|
||||
|
||||
# Fake SNS Wrapper (so wie deine Lambda es erzeugt)
|
||||
# Fake SNS wrapper (same format as ses_sns_shim_global.py)
|
||||
SQS_BODY=$(jq -n \
|
||||
--arg sesData "$SES_DATA" \
|
||||
--arg ts "$TIMESTAMP" \
|
||||
|
|
@ -135,35 +137,32 @@ SQS_BODY=$(jq -n \
|
|||
Timestamp: $ts
|
||||
}')
|
||||
|
||||
aws sqs send-message \
|
||||
SQS_MSG_ID=$(aws sqs send-message \
|
||||
--queue-url "$QUEUE_URL" \
|
||||
--region "$AWS_REGION" \
|
||||
--message-body "$SQS_BODY" \
|
||||
--output text \
|
||||
--query 'MessageId'
|
||||
--query 'MessageId')
|
||||
|
||||
echo " ✓ SQS Message eingestellt"
|
||||
echo " Done (SQS MessageId: ${SQS_MSG_ID})"
|
||||
|
||||
# --- Aufräumen ---
|
||||
# --- Cleanup ---
|
||||
rm -f "$TMP_FILE"
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo " ✅ Test-Mail eingestellt!"
|
||||
echo " Test email placed successfully!"
|
||||
echo "============================================================"
|
||||
echo ""
|
||||
echo " Jetzt Worker-Logs beobachten:"
|
||||
echo " Watch worker logs:"
|
||||
echo " docker logs -f email-worker --tail 50"
|
||||
echo ""
|
||||
echo " Der Worker sollte folgendes zeigen:"
|
||||
echo " 📧 Processing: ${MESSAGE_ID:0:20}... -> ${RECIPIENT}"
|
||||
echo " ✓ Forwarded via legacy SMTP ... (falls Forward-Rule existiert)"
|
||||
echo " ODER"
|
||||
echo " ✓ Delivered to ${RECIPIENT} (falls DMS-Mailbox existiert)"
|
||||
echo " Expected output:"
|
||||
echo " Processing: ${MESSAGE_ID:0:20}... -> ${RECIPIENT}"
|
||||
echo " Forwarded via legacy SMTP ... (if forward rule exists)"
|
||||
echo " OR"
|
||||
echo " Delivered to ${RECIPIENT} (if DMS mailbox exists)"
|
||||
echo ""
|
||||
echo " S3 Objekt prüfen:"
|
||||
echo " Check S3 object:"
|
||||
echo " aws s3 ls s3://${BUCKET_NAME}/${MESSAGE_ID} --region ${AWS_REGION}"
|
||||
echo ""
|
||||
echo " Falls etwas schief geht - SQS Message manuell prüfen:"
|
||||
echo " aws sqs receive-message --queue-url ${QUEUE_URL} --region ${AWS_REGION}"
|
||||
echo "============================================================"
|
||||
Loading…
Reference in New Issue