~maxgyver83/emailbook-hare

A minimalistic address book for e-mails only (mainly for aerc)
Update for Hare 0.24.2
Add system tests
Implement option to add mailbox entries

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~maxgyver83/emailbook-hare
read/write
git@git.sr.ht:~maxgyver83/emailbook-hare

You can also use your local clone with git send-email.

#emailbook-hare

A minimalistic address book for e-mails only.

#Installation

Install Hare if necessary.

Clone this repository:

git clone https://git.sr.ht/~maxgyver83/emailbook-hare

If don't have Hare installed and really don't want to install it, simply download this binary (for Linux, x86-64), about 470 kB (TODO: Add link).

If you like, copy emailbook-hare to a directory which is in your PATH (p.e. $HOME/.local/bin/ or /usr/local/bin/). (Otherwise, use always the full path.)

#Usage

#Command line

#Add a new entry like this:
emailbook-hare ~/emailbook.txt --add 'jd : John Doe <john.doe@example.com>'

Entries should look like MAILBOX or ALIAS : MAILBOX.

  • ALIAS is your personal abbreviation (optional).
  • See How a mailbox looks like (=optional display name plus e-mail address).
#Search a recipient:
emailbook-hare ~/emailbook.txt --search 'john'
emailbook-hare ~/emailbook.txt --key 'jd'
emailbook-hare ~/emailbook.txt --value 'john'

--search looks both at keys (=aliases) and values. --key and --value limit the search accordingly.

#Add all senders/recipients from an e-mail to your address book:
cat test/sample1 | emailbook-hare ~/emailbook.txt --parse --all

This skips p.e. "John Doe" <jd@example.com> when the address book already contains the same entry without double quotes (and vice versa).

Plain e-mail addresses are wrapped in angle brackets automatically.

E-mails like noreply@example.com are always ignored.

#aerc

emailbook-hare might work for other e-mail clients but it was tested only with aerc.

#Use emailbook for autocompletion of e-mail senders/recipients:

Add this line to ~/.config/aerc/aerc.conf, [compose] section:

address-book-cmd=emailbook-hare /home/user/emailbook.txt --search "%s"

Note: aerc adds double quotes and angle brackets automatically during autocompletion.

#Add binding to add all senders/recipients from current e-mail:

Add this line to ~/.config/aerc/binds.conf, [view] section:

aa = :pipe -m emailbook-hare /home/user/emailbook.txt --parse --all<Enter>

Just an example. aa stands for "add all".

You could also use a separate binding for adding only the sender:

af = :pipe -m emailbook-hare /home/user/emailbook.txt --parse --from<Enter>

#How a mailbox looks like

A mailbox is an e-mail address plus optionally a display name.

E-mail senders/recipients should be written like these examples:

  • john.doe@example.com
  • <john.doe@example.com>
  • John Doe <john.doe@example.com>
  • "Doe, Joe" <john.doe@example.com>

Normally, a mailbox is composed of two parts: (1) an optional display name that indicates the name of the recipient (which can be a person or a system) that could be displayed to the user of a mail application, and (2) an addr-spec address enclosed in angle brackets ("<" and ">"). There is an alternate simple form of a mailbox where the addr-spec address appears alone, without the recipient's name or the angle brackets.

RFC 5322, Section 3.4

Double-quote the display name if it contains other characters than:

ALPHA DIGIT ! # $ % & ' * + - / = ? ^ _ ` { | } ~

#Prior art

emailbook-hare is a rewrite of emailbook (POSIX shell script) and emailbook-janet (Janet script) which are heavily inspired by/similar to ~renerocksai/aercbook. But there are some differences:

emailbook-hare ...

  • is written in Hare,
  • doesn't add aliases automatically,
  • strips single quotes around display names (both 'xxx' and "'xxx'"),
  • strips redundant display names (p.e. "john@example.com" <john@example.com>),
  • skips noreply entries during parsing,
  • decodes encoded names like =?UTF-8?Q?M=C3=BCller?= (→ Müller),
  • only returns relevant entries for queries.

Now, this applies also to aercbook:

  • parses all recipients, not only the first line,
  • decodes encoded names like =?UTF-8?B?5byg5LiJ?= (→ 张三).