aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/make_message_id
blob: 5b0d34770ad83f6da3b2addd36fce70d902bcd66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# This generates lore-friendly message-id headers that are safe, unique, and
# provide better UX for someone using lore to retrieve messages.
#
# Instructions for using with mutt/neomutt:
#
# Save this as ~/bin/my-gen-msgid, then add ~/.mutt-fix-msgid with the following,
# fixing your path to the file:
#
# my_hdr Message-ID: <`/home/user/bin/my-gen-msgid`>
#
# then edit ~/.muttrc to add:
#
# send-hook . "source ~/.mutt-fix-msgid"
#
# I like my msgid to start with the date
msgid="$(date +%Y%m%d%S)-"
if [[ -x /bin/diceware ]]; then
	# I like memorable nonsense, so I can visually tell one message from another,
	# by looking at the lore URL, so use diceware for that
	msgid="${msgid}$(diceware --no-caps -d- -n2)-$(openssl rand -hex 2)"
else
	# Just use openssl with some extra randomness
	msgid="${msgid}$(openssl rand -hex 12)"
fi
# Don't leak my hostname, just use something that makes sense to me
echo -n "${msgid}@gregkh"