Recipient context¶
Visible To/Cc and the SMTP envelope may legitimately differ for Bcc, aliases or forwarding.
Setup¶
Prepare your values and Debian packages. CLI tests use only your local test files and configuration.
Set the intended recipients in your client. Use the sample message for this CLI test. For real mail, independently obtain the actual SMTP recipient from your own server log.
Test¶
set -euo pipefail
. /root/mailserver.env
python3 - <<'PY'
from email.parser import BytesParser
from email.policy import default
from email.utils import getaddresses, parsedate_to_datetime
from pathlib import Path
import os, re
raw = Path("/root/mail-tests/sample.eml").read_bytes()
message = BytesParser(policy=default).parsebytes(raw)
addresses = [address for _, address in getaddresses(message.get_all("To", []) + message.get_all("Cc", []))]
assert os.environ["MAILBOX"] in addresses
print("PASS: the intended visible recipient is present in your test message.")
PY
This CLI test confirms the local behavior described above. For production, send your own message using the actual client and MTA through the real sending route and verify it at a recipient you control.