Your message dated Tue, 17 May 2022 00:18:56 +0000
with message-id <[email protected]>
and subject line Bug#1009617: fixed in mailscripts 26-1
has caused the Debian Bug report #1009617,
regarding mailscripts: new script to reinject a message via sendmail:
sendmail-reinject
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
1009617: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009617
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: mailscripts
Version: 0.24-1
Severity: wishlist
Tags: patch
Attached is a patch (via git format-patch) for a script to re-inject
an existing message via sendmail. The script extracts the sender and
all recipients from the message and constructs the appropriate
sendmail command to re-send the message. This is very useful for
messages that were fcc'd but for some reason failed to make it out on
an initial pass (e.g. MTA misconfiguration). A man page is also
included.
Thanks for the useful package!
jamie.
-- System Information:
Debian Release: bookworm/sid
APT prefers testing
APT policy: (600, 'testing'), (500, 'unstable-debug'), (200, 'unstable'),
(101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.16.0-5-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages mailscripts depends on:
ii libconfig-tiny-perl 2.28-1
ii libfile-which-perl 1.23-1
ii libipc-system-simple-perl 1.30-1
ii liblist-moreutils-perl 0.430-2
ii libmail-box-perl 3.009-1
ii perl 5.34.0-3
ii python3 3.9.8-1
Versions of packages mailscripts recommends:
ii devscripts 2.22.1
ii git 1:2.35.1-1
ii libgit-wrapper-perl 0.048-1
ii notmuch 0.35-2
ii python3-argcomplete 1.12.3-0.1
ii python3-gssapi 1.6.12-2
ii python3-pgpy 0.5.4-4
Versions of packages mailscripts suggests:
ii gnutls-bin 3.7.3-4+b1
ii gpg 2.2.27-3+b1
ii gpg-agent 2.2.27-3+b1
ii gpgsm 2.2.27-3+b1
pn libdbd-sqlite3-perl <none>
ii libemail-date-format-perl 1.005-1.1
ii libio-socket-ssl-perl 2.074-2
ii libmailtools-perl 2.21-1
ii libmime-lite-perl 3.033-1
ii libtry-tiny-perl 0.31-1
pn libxml-feed-perl <none>
ii openssl 1.1.1n-1
-- no debconf information
>From 69693dcd497a2fae7f6eb7bdeb0545120b2cb0a6 Mon Sep 17 00:00:00 2001
From: Jameson Graef Rollins <[email protected]>
Date: Tue, 12 Apr 2022 13:03:53 -0700
Subject: [PATCH] new script to reinject message via sendmail
---
sendmail-reinject | 70 +++++++++++++++++++++++++++++++++++++++++
sendmail-reinject.1.pod | 41 ++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100755 sendmail-reinject
create mode 100644 sendmail-reinject.1.pod
diff --git a/sendmail-reinject b/sendmail-reinject
new file mode 100755
index 0000000..dfc18d5
--- /dev/null
+++ b/sendmail-reinject
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+
+import sys
+import argparse
+import subprocess
+
+import email
+from email.policy import default
+from email.utils import parseaddr, getaddresses
+
+
+def sendmail(recipients, message, sender):
+ """send message via sendmail"""
+ cmd = [
+ 'sendmail',
+ '-f', sender,
+ ] + recipients
+ print(' '.join(cmd), file=sys.stderr)
+ subprocess.run(
+ cmd,
+ input=message.as_bytes(),
+ check=True,
+ )
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="Reinject an email message via sendmail.",
+ )
+ pgroup = parser.add_mutually_exclusive_group(required=True)
+ pgroup.add_argument(
+ 'message', nargs='?', type=argparse.FileType('rb'),
+ help="email message path or '-' for stdin",
+ )
+ pgroup.add_argument(
+ '-i', '--id',
+ help="message ID for notmuch extraction",
+ )
+
+ args = parser.parse_args()
+
+ if args.id:
+ import notmuch2 as notmuch
+ db = notmuch.Database()
+ query = f'id:{args.id}'
+ assert db.count_messages(query) == 1, "Message ID does not match
exactly one message??"
+ for msg in db.messages(query):
+ path = msg.path
+ break
+ f = open(path, 'rb')
+ else:
+ f = args.message
+
+ # parse the email message
+ msg = email.message_from_binary_file(f, policy=default)
+
+ sender = parseaddr(msg['from'])[1]
+
+ # extract all recipients
+ tos = msg.get_all('to', [])
+ ccs = msg.get_all('cc', [])
+ resent_tos = msg.get_all('resent-to', [])
+ resent_ccs = msg.get_all('resent-cc', [])
+ recipients = [r[1] for r in getaddresses(tos + ccs + resent_tos +
resent_ccs)]
+
+ sendmail(recipients, msg, sender)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/sendmail-reinject.1.pod b/sendmail-reinject.1.pod
new file mode 100644
index 0000000..ed2ac22
--- /dev/null
+++ b/sendmail-reinject.1.pod
@@ -0,0 +1,41 @@
+=encoding utf8
+
+=head1 NAME
+
+sendmail-reinject - reinject an e-mail via sendmail
+
+=head1 SYNOPSIS
+
+B<sendmail-reinject> B<message.eml>
+
+B<sendmail-reinject> B<-> <B<message.eml>
+
+B<sendmail-reinject> B<--id> B<messageID>
+
+=head1 DESCRIPTION
+
+B<sendmail-reinject> reinjects a message to your MTA via sendmail.
+The message is read in (via path, stdin, or from notmuch via message
+ID), the sender and recipients are extracted, and the appropriate
+senmdail command is contructed to resent the message.
+
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--id>,B<-i> B<msgID>
+
+Message ID of message to reinject as know to a local notmuch database.
+Assumes the python3-notmuch package is available.
+
+=item B<--help>, B<-h>
+
+Show usage instructions.
+
+=back
+
+
+=head1 AUTHOR
+
+B<sendmail-reinject> and this manpage were written by Jameson Graef Rollins.
--
2.35.1
--- End Message ---
--- Begin Message ---
Source: mailscripts
Source-Version: 26-1
Done: Sean Whitton <[email protected]>
We believe that the bug you reported is fixed in the latest version of
mailscripts, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Sean Whitton <[email protected]> (supplier of updated mailscripts
package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Format: 1.8
Date: Mon, 16 May 2022 17:01:00 -0700
Source: mailscripts
Architecture: source
Version: 26-1
Distribution: unstable
Urgency: medium
Maintainer: Sean Whitton <[email protected]>
Changed-By: Sean Whitton <[email protected]>
Closes: 1009617
Changes:
mailscripts (26-1) unstable; urgency=medium
.
* New script: sendmail-reinject (Closes: #1009617)
- add default-mta | mail-transport-agent, python3-notmuch to Suggests
- add Jameson Graef Rollins to d/copyright
- add an entry to the package description.
Thanks to Jameson Graef Rollins for the new script.
* Run wrap-and-sort -abst.
Checksums-Sha1:
92dc30229f4e333c548a8a7711a49948f395b2e1 2211 mailscripts_26-1.dsc
ce61cb9c822700422c1fca5ad197f4cf3007d0e3 43908 mailscripts_26.orig.tar.xz
2ebd2692dbf5d0c44da622272bb1f60c728f36ba 6464 mailscripts_26-1.debian.tar.xz
Checksums-Sha256:
4f8d287c0210e85a5cf40fe31d62cbc83aa7e3555ec27c80eae776859fc1415f 2211
mailscripts_26-1.dsc
29010bf8e2807e45d5e7b7778fca2c3f960cd4587b19cfa6fccaf0292459c83d 43908
mailscripts_26.orig.tar.xz
04d84eb428437fa66d0b3d91938af6d21a47292dfa6bf2e15d1b908d0f67e282 6464
mailscripts_26-1.debian.tar.xz
Files:
46cb1278af5193fc676aa3e48efcbd95 2211 mail optional mailscripts_26-1.dsc
e48990060187e9b26ae5f14f1f68c8a9 43908 mail optional mailscripts_26.orig.tar.xz
40f54cfa3ee0b4538b71fdcfd51ac41c 6464 mail optional
mailscripts_26-1.debian.tar.xz
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEm5FwB64DDjbk/CSLaVt65L8GYkAFAmKC5fUACgkQaVt65L8G
YkAfEg//V1F/7OriZ52CGhouE/4nXy5nx8Ua3TYF6M388MMp0Ad+7rRe7ofdHOBw
3Dsk+3E5vbbrTYp/r4pQ5Z/dXf7lppDS/ZYkQNmEO3xFmJiNHN4co/fvOGyKUIzh
ugbzaf1dzQJWAj75pcQcbsvt97xxD8j4OStg1GmHO36hCzmBsPXj3/n1KlbyoqTu
A9VRx1B7l5SABvFuQDp8dtmk+08fFg69uNJJTxGr3tYNZz7i1nBEBnxTEi6svJA4
uFJTRx2WmuuUqR9y+m3MfKo2nlJsiIX9cPw43QpJ5XgYhj2a3s4mVugYngRpCyXo
Ki1j+U7r5lG1FtG8Ok6KeN2NhH4/GmGDGVfSQS1an361fh/9VHY7nIRpLAryfm80
3X7oJy2BR89Jo598QM71f0RFyv7CJiAmpDbzMpsMkSC+xJ3ul4RQ2KBFhGzxCZKH
m8prxISQFubMPWtkP8CV8+aOSA2mOGsrWVtaOBkby+fqoLwXV1yRezkE51+CKmEM
4QfI8UXUYl81HvCc8Bbt7Bg6djZ9Sr4Mmp3g3z0pjP47YMPmUqf9KFcNAD3zXk+o
hO7VS9ivG61U578wTqdKtOj7g4fCLYsBFJ+F40sUBGDCSYgaMqLaJt9PsRAFJvMj
KR4DPwf3q9F9RIy4AmKOcxPbIPOziJmnQkLJU0O/U/Y3nrBJWyQ=
=yf0u
-----END PGP SIGNATURE-----
--- End Message ---