this is how i manage my email configuration across my unix systems, along with notes on alternative methods in case i want to try them. this is a set of notes to self, and is not guaranteed to be correct. -- TABLE OF CONTENTS --------------------------------------- - preface - my process - environment variables - mbox, maildir, and mh file formats - common ports - pop3, imap, smtp, jmap - mbsync, mpop, msmtp - mpop configuration - mbsync configuration - notmuch - alpine config - other clients - nmh and mh-e - pgp encryption and email -- PREFACE ------------------------------------------------- i put my mail in ~/.local/share because i don't really need it to be in my home directory, as i'm only ever indirectly editing it through a client. i have different dirs for different formats, for example: - maildir mail goes in ~/.local/share/maildir/ - mbox mails go into ~/.local/share/mbox/ if you have multiple mail addresses, it might be wise to set subfolders like ~/.local/share/mbox/account1/ i set environment variables and i use external MRAs and SMTP clients when i can. -- MY PROCESS ---------------------------------------------- i use maildir. mbox feels clean, but if you receive images or lots of mail, your mbox files can become large, and inserting/deleting blocks from large files can be expensive. that being said, alpine is amazing. i use mpop when can, as it's small and supports savng mail to both maildir and mbox. otherwise i use mbsync. i use notmuch and its emacs frontend on my main computer. sometimes i use mutt. on remote systems where i receive less mail, i tend to use alpine when i use mutt i use nano as my editor. sometimes i use ed, as a novelty. i try to have a small and simple configuration. this article has a lot of data in it because it covers a couple different formats and clients. -- ENVIRONMENT VARIABLES ----------------------------------- i set a few environment variables in my ~/.profile so that i don't have to change as many settings in my mail clients. for example, when i set 'EMAIL', i no longer need to set 'user-mail-address' in emacs. MBOX -- $HOME/.local/share/mbox/mbox -- Path to your mbox file (default ~/mbox) MAILDIR -- $HOME/.local/share/maildir -- Path to your maildir directory. EMAIL -- my@addre.ss -- Your email address. This is usually the 'From:' header -- Uh maybe this is also a spool file? EDITOR -- nano -- What you'll use to edit an email before sending/replying MAIL -- $HOME/.local/share/mbox/spool -- by default this is /var/mail/wapakosis, and i keep -- it that way on some machines. -- usually, a MUA puts files from this spool into an inbox -- file, so don't use it as a main inbox file. NAME -- wapakosis -- your full name (can be multiple words) SIGNATURE -- (unset cause i don't use one :3) -- some programs instead look for a ~/.signature file SMTPSERVER -- name of the smtp server mail.tilde.green MAILHOST -- mail.addre.ss "pop://user@MAILHOST:port" TZ -- America/Edmonton my current timezone, so timestamps work maybe? -- MBOX, MAILDIR, AND MH FILE FORMATS ---------------------- 'mbox' is the 'standard' unix mailbox format. mbox files can hold multiple messages per file. used by rmail and alpine. supported by mutt. 'maildir' is newer and very popular. like mh, it also stores mail to separate files. i forgor the difference really. 'mh' stores each message into its own file. mh is used by claws mail and emacs' mh-e MUAs. i find it less intuitive than the above two, but it is usable :3 -- COMMON PORTS -------------------------------------------- i'm gonna put an asterisk by the port that i most commonly use: - 25 - plaintext SMTP port, often blocked by other servers - 2525 - alternative to port 25 that can be TLS encrypted * 587 - IANA registered this as the secure SMTP port, but supports plaintext if TLS isn't available. - 456 - works over implicit SSL - 110 - default POP3 plaintext port * 995 - secure POP3 port. - 143 - default IMAP port that does not provide encryption * 993 - secure IMAP port that works over TLS/SSL encryption -- POP3, IMAP, SMTP, JMAP ---------------------------------- POP3 - Post Office Protocol v3 (RFC 1081) - An application-layer internet protocol used to retrieve email from a server. a common misconception is that POP3 will always delete your mail from the remote inbox, but this is not the case. IMAP - Internet Message Access Protocol (RFC 9051) - another protocol that supposedly is better at management via multiple client applications, but i need to do more reading about it :D SMTP - the Simple Mail Transfer Protocol (RFC 5321) - used for sending an email! JMAP - JSON Meta Application Protocol (RFC 8621) - much less popular but newer than IMAP, made to address some shortcomings in existing protocols. not a lot of server software supports it as of writing this. -- MBSYNC, MPOP, MSMTP ------------------------------------- when i can help it, i use external programs to receive and send mail. that way, i can hop between different clients without needing to do too much configuration as long as i know how to set an 'MRA' (mail-retrieval agent) and an 'MTA' (mail-transfer application) an efficient way of thinking about mail is breaking it down into 3 parts: receiving, managing, and sending. you do these with 3 different programs: - MRA -- a Mail Retrieval Agent (mbsync, mpop, movemail) - MUA -- a Mail User Agent (mutt, alpine, claws) - an SMTP client (msmtp, sendmail, smtp) the 'email server' that is run on the remote (or local) machine lke exif, sendmail, and dovecott is called an MTA) an MRA includes 'mpop' (sometimes the package is called 'isync'). this pulls mail from a remote inbox, and into a local inbox file that you point your MUA (mail user agent) towards. -- MPOP CONFIGURATION -------------------------------------- here's an example mpop configuration file (~/.config/mpop/conf) #-- START -------------------------------------- defaults tls on tls_starttls off keep on account default host mail.example.com port 995 user me@example.com passwordeval "gpg -qd ~/.local/pass.txt.gpg" delivery mbox ~/.local/share/mbox/spool uidls_file ~/.local/share/mpop_uidls #-- END ---------------------------------------- -- MBSYNC CONFIGURATION ------------------------------------ if mpop isn't available, mbsync usually is (sometimes it's called 'isync' in some package repositories). mbsync only handles maildir and not mbox. configuration file (~/.config/isyncrc) : #-- START ---------------------------------------- IMAPStore me@example.com-remote Host "mail.example.com" Port 993 User "wapakosis" Pass "MyPassWord5" TLSType IMAPS MaildirStore my@example.com-local Subfolders Verbatim Path ~/.local/share/maildir/ INBOX ~/.local/share/maildir/INBOX Flatten . Channel me@example.com Far :me@example.com-remote: Near :me@example.com-local: Patterns INBOX drafts sent trash SyncState * Create both Expunge both MaxMessages 0 #-- END ------------------------------------------ -- NOTMUCH ------------------------------------------------- i set my environment variable NOTMUCH_CONFIG to: ~/.config/notmuch/conf in ~/.config/notmuch/default/hooks/pre-new : #!/bin/bash mbsync --pull main in ~/.config/notmuch/conf : # this is usually generated by notmuch [database] path=/home/wapakosis/.local/maildir/green [user] name=wapakosis primary_email=wapakosis@example.com When you run 'M-x notmuch' in emacs, you'll see the welcome screen. press 'm' to start writing a message 'C-c RET C-e' -- -- ALPINE CONFIG ------------------------------------------- -- OTHER CLIENTS ------------------------------------------- other clients that people tend to enjoy include: - rmail, m4ua, mew, wanderlust, and gnus (all for emacs) - exmh, MH, TCL/Tk - claws mail, MH, GTK2 - aerc, maildir, notmuch, go -- NMH AND MH-E -------------------------------------------- i don't use this, but for the sake of documentation... nmh (new mail handler) is a set of utilities that uses the Mail Handler file format for mail. i fetch a mail from the server using fetchmail, which puts the mail in a mbox spool (known by nmh as a 'maildrop'). then, i run '/usr/bin/mh/inc' (sometimes its just '/usr/bin/inc') which moves the mail from the maildrop into a set of files. i set the MH environment variable so that it's not in my homedir ~/.mh_profile : export MH="$HOME/.config/mh_profile" then, in ~/.config/mh_profile : #: - START --------------------------------------- #: paths are relative to home. Path: .local/share/mh Local-Mailbox: wapakosis send: -mts sendmail/pipe -sendmail /usr/bin/msmtp MailDrop: .local/share/mh/spool.mbox #: - END ----------------------------------------- -- PGP ENCRYPTION AND EMAIL -------------------------------- so i think it's kinda weird to have pgp facilities in my mua. i don't mind downloading an encrypted message to my machine and decrypting it myself. that way i can have mails encrypted with other keys like ssh or age, and not need to deal with figuring out how i'm supposed to "make pgp work" with whatever client i'm using. it's a big load off my expectations for what a "feature-complete MUA" is. that being said: [TODO] -- END ----------------------------------------------------- by wapakosis gopher://inlisp.org/1/users/wapakosis