$ man -S pkg mailx
to ensure you are reading Heirloom mailx documentationTable of Contents
Heirloom mailx (formerly nail)
Part of the now-defunct Heirloom Project, Heirloom mailx “provides traditional implementations of standard Unix utilities”, largely derived from original Unix material which was released as open source by Caldera and Sun Microsystems. Active development stopped around 2010 but some security patches have been applied to the NetBSD package version since and until something new comes along to break it it will likely remain available via PkgSrc. The various features and somewhat interesting history of Heirloom mailx is available on it's homepage.
Documentation and Features
The Heirloom mailx(1) manpage1) is the best place to learn all it's features but the standouts are:
- POP3/IMAP/SMTP support
- account-specific folder-hooks
- definable macros
- command and folder aliases
- threading that actually works
There is also some rudimentary Bayesian filtering for dealing with junk mail, a drafts
command for message templates, and even some support for encrypting/decrypting messages.
Setup
Avoiding name collision
Heirloom mailx installs as /usr/pkg/bin/mailx
which may cause name collision with the native NetBSD mail/mailx client so it's a good idea to create a command alias for your SDF shell:
alias nail='/usr/pkg/bin/mailx' # sh, ksh, pdksh, bash shells alias nail '/usr/pkg/bin/mailx' # csh & tcsh shells
Typing nail
(the old client name) will now launch Heirloom mailx. Adding the appropriate alias to your shell's configuration file will make it available each time you log in. A launch script placed under ~/bin/
is another option.
Configuration
The default user configuration file for Heirloom mailx is ~/.mailrc
, unfortunately also used by the native NetBSD mail(1) client. If you never plan to use native mail(1) then you can go ahead and put all your settings in ~/.mailrc
; chances are the native mail(1) will just ignore any settings it doesn't understand. A somewhat better option which maintains settings separation is to create a minimal ~/.mailrc
and add the following to it:
set NAIL_EXTRA_RC=~/.nailrc
This will allow occasional / accidental use of the native mail(1) client and keeps all the “nail-specific” settings in ~/.nailrc
. Alternately, it's possible to unset MAILRC and set NAILRC (shell environment variables) on-the-fly via a launch script for settings separation.
A basic SDF specific Heirloom mailx configuration (using both ~/.mailrc and ~/.nailrc):
- ~sdfuser/.mailrc
## ~sdfuser/.mailrc # Set top of mail folder tree to ~/mail: set folder=mail # Tell Heirloom mailx where to get additional configurations: set NAIL_EXTRA_RC=~/.nailrc
- ~/.nailrc
## ~sdfuser/.nailrc file - use with /usr/pkg/bin/mailx # *** GLOBAL SETTINGS SECTION *** # Note: # Set variables _persist_ until the session ends # unless unset or reset. Type 'set' to display # current settings. # Use alternate SMTP server (bypasses default SMTP): #set smtp-auth="login" #set smtp-auth-user="myacct" #set smtp-auth-password="secret" #set smtp=smtps://lavabit.com:465 # Set SSL Cert check method ("ask" is default). # Will likely need "ignore" for accessing alternate # SDF accounts when the SSL certs are expired. #set ssl-verify="ask" set ssl-verify="ignore" #set ssl-no-default-ca #set ssl-v2-allow # Set directory where "folders" should look for mail folders # (generally not needed if set in ~/.mailrc) #set folder=mail # Set MBOX (defaults to ~/mbox): #set MBOX="~/mail/Saved" # Have nail retain copies of outgoing msgs: set record="~/mail/Sent" # Set dead.letter location (default is ~/dead.letter) #set DEAD="~/mail/dead.letter" # Retain the specified headers: retain User-Agent bcc cc date from subject to # Only retain the specified headers when saving messages: saveretain bcc cc date from subject to # Start regardless of whether msgs are in /var/mail/<user>: set emptystart # Set From: and ReplyTo: header fields: # (default is your GECOS data) #set from="SDF User<sdfuser@sdf.org>" #set replyto="metoo@tenex.org (Me Too)" # Set AUTOSORT criteria: #set autosort=thread # Set signature file: #set signature="~/.signature-nail" # Have original msg text quoted in Replies: set quote # Specify what should be prompted for before sending msgs: set askcc set askbcc set askattach # Turn off autoprint so that 'd' _doesn't_ print the next message: #unset autoprint # Have html-based msgs piped thru lynx: set pipe-text/html="lynx -dump -nolist -stdin" # *** SUB-FOLDER SHORTCUTS SECTION shortcut saved +Saved shortcut sent +Sent shortcut draft +Draft # *** GROUP ALIASES *** # (note: cc/bcc mailings need to have at least one To: entry) alias hop-list hoppy@mud.bog \ mrwarts@mud.bog \ froggy@mud.bog alias bounce spam@uce.gov consumer.hotline@doj.state.or.us # *** ALIASES *** alias gopher "Gopher Project Discussion <gopher-project@lists.alioth.debian.org>" alias nail-devel nail-devel@lists.sourceforge.net alias netbsd-users "NetBSD Users list <netbsd-users@netbsd.org>" # *** MACRO DEFINITIONS SECTION *** # run by typing 'call <macro>' or using folder-hooks # home - return to /var/mail/$USER and reset applicable variables. # Useful for getting back to local mail folders from IMAP accts. define home { fi /var/mail/$USER set folder="~/mail" set record="~/mail/Sent" shortcut saved +Saved shortcut sent +Sent shortcut draft +Draft set from="SDF User<sdfuser@sdf.org>" set replyto="metoo@tenex.org (Me Too)" } # uas - Unset Alternate SMTP variables define uas { unset smtp-auth unset smtp-auth-user unset smtp-auth-password unset smtp } # *** Remote IMAP ACCounts Section (no POP3) *** # Note: ALL outgoing messages are processed LOCALLY unless an # alternate MTA/SMTP server is set globally (see defaults above) # or within an 'account'. Also, variables set in IMAP accounts # persist until session endsunless unset/reset. Type 'set' to see # current settings, 'ac' for defined accounts. IMAP accounts are # not cached locally unless "imap-cache" is set. # Set local caching of remote IMAP accounts: #set imap-cache="~/mail/.imap-cache" # Typical SDF user IMAP acct setup w/ SSL encryption: account sdfuser2 { set folder=imaps://sdfuser2@mx.sdf.org/mail/ set record=+Sent shortcut sent +Sent shortcut saved +Saved set from="SDF User2<sdfuser2@sdf.org>" set replyto="SDF User2<sdfuser2@sdf.org>" set password-sdfuser2@mx.sdf.org="********" } ### note: due to 2022 Gmail policy change this no longer works ### # Typical Gmail IMAP/SMTP w/ SSL setup # (need to enable IMAP access first) account gmail { set hold set folder=imaps://gmail.user\@gmail\.com@imap.gmail.com/INBOX shortcut sent "imaps://gmail.user@gmail.com@imap.gmail.com/[Gmail]/Sent Mail" shortcut spam "imaps://gmail.user@gmail.com@imap.gmail.com/[Gmail]/Spam" set record=sent set from="gmail.user@gmail.com" set replyto="gmail.user@gmail.com" set password-gmail.user\@gmail\.com@imap.gmail.com="**********" ## gmail SMTP server stuff: set smtp-gmail.user\@gmail\.com=smtps://smtp.gmail.com set smtp-auth-user-gmail.user\@gmail\.com="gmail.user@gmail.com" set smtp-auth-password-gmail.user\@gmail\.com="**********" }