A wrapper for your local mail transfer agent (MTA) that initiates an SSH session when your SDF email address appears in the “From:” header.
You want to send email from your SDF address without running the risk that the receiving server will reject it due to a mismatch between the “From” header and your ISP's IP block, but …
a *BSD, Linux, or WSL environment with a client that generates MIME-formatted mail (as expected by sendmail-compatible MTAs such as msmtp)
#!/usr/bin/env bash
#
# msmtp.wrap - bypass local in favor of remote sendmail,
# if certain headers are found
PATH=/bin:/usr/bin:/usr/local/bin
Account0=me@sdf.org
Account1=me@other-pubnix.net
MTA=msmtp
draft="$(mktemp -t sendmail.XXXXXX)"
cat /dev/stdin > "$draft"
sender="$(grep '^From:' "$draft" | head -n 1 | cut -d: -f2)"
case "$sender" in
*$Account0*)
sendmail="ssh $Account0 sendmail -t" ;;
*$Account1*)
sendmail="ssh $Account1 sendmail -t" ;;
*)
sendmail="$MTA $*" ;;
esac
< "$draft" $sendmail; status=$?
rm -f "$draft"; exit $status
The possibilities for customization of this wrapper are only limited by your imagination. You can parse the outgoing messages to look for particular recipients, subject lines, etc., and define a custom $sendmail command to handle each case. On the SDF side, the arguments following ssh $Account0 will be passed to your usual login shell after the -c option1), so you will enjoy all the environment variables defined in $HOME/.bash_login if you use bash as your login shell. Save your custom scripts in a directory that your SDF login shell considers part of $PATH, and you can then perform all kinds of tasks (like updating your website) without leaving your mail client.