Re: [patch] Remind about attachments before sending
On Mon, Jan 24, 2005 at 06:41:33PM +0100, Moritz Muehlenhoff wrote:
> The patch has been sent to this list once, but didn't seem to have caught
> attention. I've resynced the patch against current CVS, please consider
> inclusion.
Yes, it is a useful feature, but...
0. It can be implemented as $sendmail wrapper.
e.g. set sendmail="/usr/local/bin/checkattach_and_sendmail attached"
and write it like...
#!/bin/sh
[ "$#" = 1 ] || exit 1
TEMPFILE=`mktemp /tmp/checkattach.XXXXXX` || exit 1
cat >> $TEMPFILE
if grep -qi "$1" "$TEMPFILE"; then
grep -qi 'Content-Type:.*multipart' "$TEMPFILE" || \
( rm -f "$TEMPFILE" ; exit 1 )
fi
/usr/sbin/sendmail -oem -oi < "$TEMPFILE"
RETURNVAL=$?
rm -f "$TEMPFILE"
exit $RETURNVAL
1. The code is not so clean.
1.a. It has hardcoded numbers.
e.g.
> + char* inputline = malloc(1024);
1.b. It can't handle multibyte strings.
e.g.
> + lowerKeyword[i] = tolower(AttachKeyword[i]);
1.c. It doesn't do i18n.
> + char errorstr[512];
> + if (snprintf(errorstr, 512,
> + "Message contains magic keyword \"%s\", but no
> attachments. Not sending.", AttachKeyword)==-1)
> + errorstr[511] = 0; // terminate if need be. our string shouldnt
> be this long.
> + mutt_error _(errorstr);
--
tamo