
Kyle Lahnakoski writes:
I am setting up an email list for my local community (just myself right now). Being a nerd, I am using Amazon SES to send and receive emails.
Outgoing SES is full of unpleasant surprises. In particular, they restrict use of certain headers (DKIM-Signature is the most important one from Mailman's point of view) and commandeer Message-ID (which means archivers and explicit addressees see a different Message-ID from the one subscribers see).
I have mailman installed on ec2 (using "pip install mailman") and it is working well enough to send an email to the list with
/opt/mailman/venv/bin/mailman inject -f <somefile>all@mymaillist.org
SES is putting incoming mail into an S3 bucket, one file per email. Using a small python program, I use the above command to send them to the list.
It's not obvious to me how to make this work for administrative traffic. As Mark says, it needs to find its way into the 'command' queue ('-q command'), but you may also need to specify what the command is (ie, the extension such as '-join' or '-confirm') using added metadata (the '-m' option, see 'mailman inject -h'). I don't know offhand what the format of that would be, though. (I mention that because 'mailman inject -h' specifies that the target argument is a LISTSPEC, either the List-ID or the posting address, which would not include the extension that tells Mailman what to do with the message. Just putting it in the command queue is probably enough, though.)
As far as I know, SES does no filtering incoming. If that's true, you would make life a lot easier by installing an MTA and having it relay incoming mail to Mailman as usual, rather than queuing the mail in an S3 bucket (saving the cost of the bucket). If I'm wrong, you have to trade off the benefit of filtering vs. simplicity in your operations.
Alternatively, using the 'LMTP' class from 'smtplib' your Python script is almost a one-liner. You get the intended recipient from 'Delivered-To' (if it exists, if not life is considerably more complex), the sender from 'Sender' or 'From', and just pass that on to the LMTP object's send method to send to localhost:8024 (assuming the default port).
Steve