Commit 15b6b524 authored by Olaf Meeuwissen's avatar Olaf Meeuwissen
Browse files

Add Emacs mail sending intergration

This (finally) adds the wrapper script I have been using with Emacs to
get my upstream mail server to accept my mail even when I sent from an
address different from that of my account.
parent dd1ae80d
;;; ~/.emacs.d/60-mail.el -- integration and customisation
;;; Copyright © 2020 Olaf Meeuwissen <paddy-hack@member.fsf.org>
;;;
;;; SPDX-License-Identifier: GPL-3.0-or-later
;; Use an external program that sweeps the system's mail sending
;; idiosyncracies under the rug.
(setq-default send-mail-function 'sendmail-send-it
sendmail-program "~/bin/masqmail")
#! /bin/sh
# ~/bin/masqmail -- sweep local mail system idiosyncracies under the rug
# Copyright © 2020 Olaf Meeuwissen <paddy-hack@member.fsf.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later
DEBUG=yes
SPOOL=$HOME/var/spool
LOGDIR=$HOME/var/log
LOGFILE=$LOGDIR/masqmail.log
DMA_PROG=/usr/sbin/dma
AUTHFILE=$HOME/etc/dma/auth.conf
test -d $SPOOL || mkdir -p $SPOOL
tmpfile=`mktemp -p $SPOOL masqmail.XXXXXX`
trap "rm $tmpfile" 0 1 2 15
cat - > $tmpfile
if test "x$DEBUG" = xyes; then
test -d $LOGDIR || mkdir -p $LOGDIR
cat <<EOF >> $LOGFILE
----------------------------------------------------------------------
`date '+%FT%T'`: $0 $@
----------------------------------------------------------------------
EOF
cat $tmpfile >> $LOGFILE
fi
# Work around a bug in dma (see bts:748901) that is triggered by emacs'
# message-mode which tries to comply with RFC2822 and keep header lines
# within a 78 character line length recommendation (see RFC2822 section
# 2.1.1). This may lead to addresses getting split over two lines. We
# concatenate the relevant headers.
# FIXME: dma still and rightly chokes on header that are too long! The
# concatenated headers should be split on commas.
exec \
sed -e '/^To: /{ :to; N; s/\n / /; t to; P; D }' \
-e '/^Cc: /{ :cc; N; s/\n / /; t cc; P; D }' \
-e '/^Bcc: /{ :bcc; N; s/\n / /; t bcc; P; D }' \
< $tmpfile \
| $DMA_PROG -i -t -f ${EMAIL:-$(sed '/^#/d; s/|.*//' $AUTHFILE)}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment