#!/bin/sh -efu . shell-signal cleanup_function() { [ -z "$tmpdir" ] || rm -rf -- "$tmpdir" } tmpdir="$(mktemp -dt "${0##*/}.XXXXXXXX")" set_cleanup_handler cleanup_function cat > "$tmpdir/orig_mail" orig_from="$(formail -z -x "From:" <"$tmpdir/orig_mail")" who="$(formail -z -x "X-Bugzilla-Who:" <"$tmpdir/orig_mail")" formail -I "Sender: $orig_from" -I "From: $who" <"$tmpdir/orig_mail"