💾 Archived View for tilde.pink › ~emily › log › clean-email.gmi captured on 2022-07-16 at 14:33:45. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2023-01-29)

-=-=-=-=-=-=-

clean unixy email

i got my "non-emacs" email management configured to the point where it works. I'm using 'mailutils' and 'msmtp' for everything!

configuration

i'll split this up into 'sending', 'receiving', and 'managing'.

sending

the msmtp program allows you to send email using smtp. it's small but it works well!

# inside ~/.config/msmtp/config

defaults
port 587
tls on
account main
host mail.eample.com
from me@example.com
auth on
user me@example.com
password mypassw0rd
account default : main

there isn't much to explain here, which is nice. be sure to set the permissions of this file so that only you can access it, with:

chmod 600 ~/.config/msmtp/config

you can test that your msmtp config works by trying to send an email:

echo -e "Subject: test\nHello! This is a test!" \
        | msmtp -a default some-address@example.com

receiving

we want to be able to receive mail by copying mail from our remote mailbox to our local spoolfile. 'mailutils' comes with 'movemail' which does this! i made the following script to do this:

# inside ~/.local/bin/my-mail

movemail -p me%40example.com:mypassw0rd@mail.example.com \
            /var/spool/mail/emily

now i can run the 'my-mail' script whenever i want to check for new mail, and it adds new mail to my spoolfile! you should also 'chmod 600' this file, since your password is here, too!

the '-p' flag means 'preserve', as in "keep the mail on the server instead of deleting it!". since this machine isn't my main machine, i only want to copy my mail, not move it!

on my main computer, i do not have the -p flag.

managing

the 'mailutils' package comes with 'mail', which is a client for accessing those mbox files! my config for 'mail' is shown here:

# inside ~/.mailrc

set dot
set save
set asksub
set hold
set emptystart
set outfolder=~/
set mta=/usr/bin/msmtp
set headline "%>\ %a\ %2m\ %15s\ %D{%b\ %d}\ %15f"

ignore Received Message-Id Mail-From Return-Path Via

you can view your mailfile by running 'mail', or send an email to a friendo with 'mail some-address@example.com'.

this config file is a little bit more vague. 'info mailutils mail' has a good summary, but here's what i set:

'dot' - 'dot' means that, when you're sending a mail, a single dot on a blank line means "i'm done editing. send the email" (yes, 'ed' style!)

'save' - if you cancel out of sending a mail, 'save' creates a backup just in case.

'asksub' - when you write a new, 'asksub' means that mail will prompt you for a subject line, which is nice.

'hold' - instead of throwing all the mail in your spoolfile into '~/mbox', it stays in the spoolfile when you quit. i prefer this because i like to sort my mail into multiple different files (like, a file for 'friends' and a file for 'not-friends', pretty much)

'emptystart' - if there's no mail in your spoolfile, mail won't even start, but sometimes i want to check the 'help' menu to refresh my memory, so i like to be able to start the client whenever!

'outfolder' - when i use 'save friends' to output my current email to my 'friends' file, mail puts it in my homedirectory by default.

'mta' - the mail-transfer-agent. set this to msmtp so mail uses msmtp to send mail!

'headline' - this is how the mails look in your inbox. mine is set as such:

active mail, read status, subject, date, sender

you can also do colours with ascii escapes on some machines, like:

set header "\033[95m%2m\ \033m[93m%15s\ \033[95m%15f"

although i'm not here to talk about ascii colour escapes. i'm just a whore for ascii colours and had to mention it.

'ignore' - alright this was useful. sometimes emails have lots of headers that you just don't care to see. whenever a particularly large or abnoxious header shows up and blocks the whole screen, i can simply ignore it by adding it to this list! handy. yessir!

more security

i mentioned it before, but i'll stress it again: make sure no-one can access any file that has sensitive information (passwords) in it:

chmod 700 ~/.local/bin/my-mail
chmod 600 ~/.config/msmtp/config

msmtp allows you to use gpg to store a password by using the following line instead of the 'password' line in your msmtp config:

passwordeval gpg2 --no-tty -q -d ~/.config/msmtp/pass.gpg

movemail allows the use of a 'tickets file', located at ~/.mu-tickets. it looks something like this:

# .mu-tickets file
imap://me%40example.com:mypassw0rd@mail.example.com

then in your 'my-mail' script, you may omit the password field. i don't know if you can encrypt the mu-tickets file yet, though (i'll update this post after i try)

frustrations

i can't seem to get 'mail' to open vim to write mail. i'm stuck using mail's crappy built-in editor, which forces bottom-posting rather than inline replies! this is the only thing stopping mail from being super comf.

i wanted to try using a different mail-retreival-agent (mra), but after enough trying, i stuck with movemail. hey, at least i tried!

march 10, 2021