mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
This patch implements the first steps of support for IDNA (Internationalized Domain Names for Applications). Internally, we maintain the byte-agnostic representation, including configuration. We support receiving IDNA mail over SMTP, which we convert to unicode for internal handling. Local deliveries are still kept agnostic. For sending over SMTP, we use IDNA for DNS resolution, but there are some corner cases pending in the SMTP courier that are tied with SMTPUTF8 and will be fixed in subsequent patches.
31 lines
815 B
Python
Executable File
31 lines
815 B
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Simple SMTP client for testing purposes.
|
|
|
|
import argparse
|
|
import email.parser
|
|
import email.policy
|
|
import smtplib
|
|
import sys
|
|
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--server", help="SMTP server to connect to")
|
|
ap.add_argument("--user", help="Username to use in SMTP AUTH")
|
|
ap.add_argument("--password", help="Password to use in SMTP AUTH")
|
|
args = ap.parse_args()
|
|
|
|
# Parse the email using the "default" policy, which is not really the default.
|
|
# If unspecified, compat32 is used, which does not support UTF8.
|
|
msg = email.parser.Parser(policy=email.policy.default).parse(sys.stdin)
|
|
|
|
s = smtplib.SMTP(args.server)
|
|
s.starttls()
|
|
s.login(args.user, args.password)
|
|
|
|
# Note this does NOT support non-ascii message payloads transparently (headers
|
|
# are ok).
|
|
s.send_message(msg)
|
|
s.quit()
|
|
|
|
|