summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog31
-rw-r--r--debian/control10
-rw-r--r--debian/copyright1
-rw-r--r--debian/mailscripts.install4
-rw-r--r--debian/mailscripts.manpages4
-rwxr-xr-xgmi2email9
-rw-r--r--mailscripts.el11
-rwxr-xr-xmdmv2
-rwxr-xr-xnotmuch-slurp-debbug6
-rwxr-xr-xsendmail-reinject73
-rw-r--r--sendmail-reinject.1.pod45
11 files changed, 174 insertions, 22 deletions
diff --git a/debian/changelog b/debian/changelog
index dc32b82..759a89b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,31 @@
-mailscripts (0.24-1) UNRELEASED; urgency=medium
+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.
+
+ -- Sean Whitton <spwhitton@spwhitton.name> Mon, 16 May 2022 17:01:00 -0700
+
+mailscripts (25-1) unstable; urgency=medium
+
+ * notmuch-slurp-debbug:
+ - Exit immediately if Mail::Box::Manager::open fails.
+ - Support tilde expansion in 'maildir' configuration key.
+ * mdmv: ensure destination path ends with ':2,' when message has no flags.
+ Previously we were writing some messages with no flags into cur/
+ directories without this suffix, which is invalid (see maildir(5)).
+ * mailscripts.el: change mailscripts-project-library default to `project'.
+ Now that Emacs 28.1 is out, the latest stable release of Emacs
+ contains a more fully-featured version of project.el, so change the
+ default as we said we would.
+ * Drop the '0.' prefix to mailscripts version numbers.
+
+ -- Sean Whitton <spwhitton@spwhitton.name> Mon, 04 Apr 2022 18:07:45 -0700
+
+mailscripts (0.24-1) unstable; urgency=medium
* mailscripts.el:
- Enable lexical binding.
@@ -11,7 +38,7 @@ mailscripts (0.24-1) UNRELEASED; urgency=medium
- Cope with XML feeds sent with text/gemini MIME type.
* notmuch-extract-patch(1): add link to the piem project.
- -- Sean Whitton <spwhitton@spwhitton.name> Fri, 07 Jan 2022 14:21:25 -0700
+ -- Sean Whitton <spwhitton@spwhitton.name> Fri, 07 Jan 2022 14:48:01 -0700
mailscripts (0.23-1) unstable; urgency=medium
diff --git a/debian/control b/debian/control
index 763e8e9..5753610 100644
--- a/debian/control
+++ b/debian/control
@@ -60,14 +60,16 @@ Suggests:
gpg,
gpg-agent,
gpgsm,
- openssl,
libdbd-sqlite3-perl,
+ libemail-date-format-perl,
libio-socket-ssl-perl,
+ libmailtools-perl,
libmime-lite-perl,
- libemail-date-format-perl,
libtry-tiny-perl,
- libmailtools-perl,
libxml-feed-perl,
+ default-mta | mail-transport-agent,
+ openssl,
+ python3-notmuch,
Architecture: all
Description: collection of scripts for manipulating e-mail on Debian
This package provides a collection of scripts for manipulating e-mail
@@ -94,3 +96,5 @@ Description: collection of scripts for manipulating e-mail on Debian
imap-dl -- download messages from an IMAP mailbox to a maildir
.
gmi2email -- subscribe to gemlogs and read individual Gemini pages by e-mail
+ .
+ sendmail-reinject -- reinject an e-mail message via sendmail(1)
diff --git a/debian/copyright b/debian/copyright
index 1d246a9..f4fee59 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -4,6 +4,7 @@ Collection of scripts for manipulating e-mail on Debian
Copyright (C)2017-2021 Sean Whitton
Copyright (C)2019-2020 Daniel Kahn Gillmor
Copyright (C)2020 Red Hat, Inc.
+Copyright (C)2022 Jameson Graef Rollins
These programs are free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
diff --git a/debian/mailscripts.install b/debian/mailscripts.install
index 53665b3..f097f49 100644
--- a/debian/mailscripts.install
+++ b/debian/mailscripts.install
@@ -1,11 +1,11 @@
email-extract-openpgp-certs /usr/bin
email-print-mime-structure /usr/bin
+gmi2email /usr/bin
imap-dl /usr/bin
maildir-import-patch /usr/bin
+mbox-extract-patch /usr/bin
mbox2maildir /usr/bin
mdmv /usr/bin
-mbox-extract-patch /usr/bin
notmuch-extract-patch /usr/bin
notmuch-import-patch /usr/bin
notmuch-slurp-debbug /usr/bin
-gmi2email /usr/bin
diff --git a/debian/mailscripts.manpages b/debian/mailscripts.manpages
index d704a87..7b5bc43 100644
--- a/debian/mailscripts.manpages
+++ b/debian/mailscripts.manpages
@@ -1,11 +1,11 @@
email-extract-openpgp-certs.1
email-print-mime-structure.1
+gmi2email.1
imap-dl.1
maildir-import-patch.1
+mbox-extract-patch.1
mbox2maildir.1
mdmv.1
-mbox-extract-patch.1
notmuch-extract-patch.1
notmuch-import-patch.1
notmuch-slurp-debbug.1
-gmi2email.1
diff --git a/gmi2email b/gmi2email
index 8be383a..5dc819c 100755
--- a/gmi2email
+++ b/gmi2email
@@ -125,7 +125,14 @@ foreach my $sub (<$subs_fh>) {
# so also look at the file extension
if ($type =~ m{^(?:text|application)/(?:(?:atom|rss)\+)?xml}
or $sub =~ /\.xml$/) {
- my $feed = XML::Feed->parse(\$data);
+ my $feed;
+ #<<<
+ try {
+ $feed = XML::Feed->parse(\$data);
+ } catch {
+ die "While parsing $sub, XML::Feed exception:\n$_";
+ };
+ #>>>
for ($feed->entries) {
my $date = $_->issued // $_->modified;
$date = $date->epoch if $date;
diff --git a/mailscripts.el b/mailscripts.el
index 8519e4f..15ed7ac 100644
--- a/mailscripts.el
+++ b/mailscripts.el
@@ -1,7 +1,7 @@
;;; mailscripts.el --- functions to access tools in the mailscripts package -*- lexical-binding: t; -*-
;; Author: Sean Whitton <spwhitton@spwhitton.name>
-;; Version: 0.23
+;; Version: 26
;; Package-Requires: (notmuch)
;; Copyright (C) 2018, 2019, 2020, 2022 Sean Whitton
@@ -48,19 +48,14 @@ Note that this does not prevent the creation of new branches."
(const :tag "Ask whether to detach" ask))
:group 'mailscripts)
-(defcustom mailscripts-project-library 'projectile
+(defcustom mailscripts-project-library 'project
"Which project management library to use to choose from known projects.
Some mailscripts functions allow selecting the repository to
which patches will be applied from the list of projects already
known to Emacs. There is more than one popular library for
maintaining a list of known projects, however, so this variable
-must be set to the one you use.
-
-Once there is a more fully-featured version of project.el
-included in the latest stable release of GNU Emacs, the default
-value of this variable may change, so if you wish to continue
-using Projectile, you should explicitly customize this."
+must be set to the one you use."
:type '(choice (const :tag "project.el" project)
(const :tag "Projectile" projectile))
:group 'mailscripts)
diff --git a/mdmv b/mdmv
index fa1533f..78a9222 100755
--- a/mdmv
+++ b/mdmv
@@ -59,7 +59,7 @@ for msg in sys.argv[1:-1]:
if flags:
msg_dest = os.path.join(os.path.join(dest, 'cur'), name_prefix + ':' + flags)
else:
- msg_dest = os.path.join(os.path.join(dest, 'cur'), name_prefix)
+ msg_dest = os.path.join(os.path.join(dest, 'cur'), name_prefix + ':2,')
if os.path.exists(msg_dest):
eprint(us + ": somehow, dest " + msg_dest + " already exists")
diff --git a/notmuch-slurp-debbug b/notmuch-slurp-debbug
index ad0db47..f5ae3fc 100755
--- a/notmuch-slurp-debbug
+++ b/notmuch-slurp-debbug
@@ -43,7 +43,7 @@ my $maildir;
my $conf_r = $ENV{XDG_CONFIG_HOME} || catfile $ENV{HOME}, ".config";
my $conf_f = catfile $conf_r, "mailscripts", "notmuch-slurp-debbug";
if (-f $conf_f) {
- $maildir = Config::Tiny->new->read($conf_f)->{_}->{maildir};
+ $maildir = glob Config::Tiny->new->read($conf_f)->{_}->{maildir};
} else {
# default to where a lot of people have their inbox
chomp(my $database_path = `notmuch config get database.path`);
@@ -54,7 +54,7 @@ $maildir = $mgr->open(
access => "a",
keep_dups => 1,
type => "maildir"
-);
+) or die "failed to open target maildir: $!\n";
# we use bts(1) to download the mbox because it has some logic to find
# the right URI and the user might have enabled its caching features.
@@ -72,7 +72,7 @@ my $mbox = $mgr->open(
access => "r",
keep_dups => 1,
type => "mbox"
-);
+) or die "failed to open $bug.mbox: $!\n";
foreach my $message ($mbox->messages) {
my $mid = $message->messageId;
diff --git a/sendmail-reinject b/sendmail-reinject
new file mode 100755
index 0000000..e50c484
--- /dev/null
+++ b/sendmail-reinject
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright 2022 Jameson Graef Rollins
+
+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', '--notmuch-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..f89d0f1
--- /dev/null
+++ b/sendmail-reinject.1.pod
@@ -0,0 +1,45 @@
+=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<-i> 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<--notmuch-id>,B<-i> B<messageID>
+
+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 SEE ALSO
+
+sendmail(1), notmuch(1)
+
+=head1 AUTHOR
+
+B<sendmail-reinject> and this manpage were written by Jameson Graef
+Rollins <jrollins@finestructure.net>.