Hans-Martin & all -
On 13.07.2023 11:00, Hans-Martin Mosner via mailop wrote:
Has anyone on this list tried forwarding (e.g. for ex-employees) via
attachment? The original message would be kept intact, while the outer
message clearly originates with the forwarding agent who may even add
a human readable reminder to the addressee to let the sender know
about the changed address.
this is what I have thought up to tackle such tasks:
------------------------------------------------------------------------
#!/bin/bash mailbody="$(grep -v '^From ' -)" today="$(date '+%d.%m.%Y')"
msgid="$(echo "$mailbody" | grep -i '^message-id:' | sed 's/^[^:]*:
//')" readarray -t recipients < ./addressees.list for i in
"${recipients[@]}" do v_mailpart="$(date '+%s%N'|sha1sum|sed 's/ .*//')"
echo "References: $msgid Subject: Forwarded email of $today for $i To:
$i From: Carsten Schiefner <carsten@schiefner.berlin> BCC:
carsten@schiefner.berlin X-Forwarded-Message-Id: $msgid In-Reply-To:
$msgid Content-Type: multipart/mixed; boundary=\"$v_mailpart\"
MIME-Version: 1.0 This is a multi-part message in MIME format.
--$v_mailpart Content-Type: text/plain; charset=\"UTF-8\"
Content-Transfer-Encoding: quoted-printable --$v_mailpart Content-Type:
message/rfc822; name=\"Attached Message.eml\"
Content-Transfer-Encoding: 8bit Content-Disposition: attachment;
filename=\"Attached Message.eml\" $mailbody --$v_mailpart--" | exim
-ti done
------------------------------------------------------------------------
The script is invoked from the .procmailrc file:
------------------------------------------------------------------------
:0 * ^To: .*[addressee's email address] | ./auto_forward_script
------------------------------------------------------------------------
The email addresses in the "addressees.list" text file should have the
format "first_name last_name <email_address>" or something similar that
will equally be understood by exim resp. your chosen MTA.
Feel free to use it and - even better! :-) - improve it. If that occurs,
please be kindly asked to share your result here again.
Cheers,
-C.
_______________________________________________
mailop mailing list
mailop@mailop.org
https://list.mailop.org/listinfo/mailop