User Tools

Site Tools


native_netbsd_mailx

Native NetBSD mail(1) Setup and Use:

This is the native mail client on NetBSD, the operating system the SDF cluster runs on. For historical reasons there are several aliases: mail(1), Mail(1), mailx(1), however sticking to the first two will avoid name collision with any non-native clients. While mail(1) has some MIME support it lacks folder-level hooks as well as POP3 or IMAP support so it may only appeal to users with modest mail needs. That said, native mail(1) is quite capable of meeting most SDF email needs.

Setup

Native mail(1) uses ~sdfuser/.mailrc for its configurations; below is an annotated sample config file which should work for most SDF users with little modification:

~sdfuser/.mailrc
### NetBSD mail(1) config file (~/.mailrc):
 
## Hold mail in system Inbox (/sdf/mail/$USER):
set hold
 
## Set top of mail folder tree & cd into it; can
## be any name but "mail" or "Mail" is typical:
# use '~/mail/':
set folder=mail
# allows simple folder changes, ex. 'fi Sent' instead of 'fi +/Sent':
chdir mail
 
## Set non-std mbox and record names/locations.
## (default loc: ~/ ; '+' prefix => ~/mail/..):
# ~/mbox is default:
set MBOX=+Save
# none is default:
set record=+Sent
 
## Header fields to ignore & retain:
ignore message-id received fcc status resent-date resent-message-id resent-from in-reply-to
retain bcc cc date from subject to user-agent organization
 
## Add additional headers - these are added to outgoing
## messages unless editted/deleted in composition mode:
Header User-Agent: NetBSD Mail version 9.1alpha 2009-02-25
Header Organization: SDF Public Access UNIX System
 
## uncomment to tweak the 'From:' field; default is
## SDF user GECOS field (use userinfo(1) to list):
#Header From: SDFuser at SDF <sdfuser@beevomit.org>
 
# Open even if no mail:
set emptystart
 
## Email aliases:
# use for contacting SDF membership:
alias sdfhelp 'SDF membership <membership@sdf.org>'
# a list of users, both local and remote:
alias wrkgrp sdfuser2 sdfuser3 rmtuser@remote.addr 'The Boss <boss@big.house>'
 
## set alt. editor(s) and pager; these will override
## user's EDITOR, VISUAL, PAGER shell env. vars:
# default is PAGER:
#set PAGER=more
# default is EDITOR:
#set EDITOR=nano
# default is VISUAL:
#set VISUAL=$HOME/bin/veditor
 
## Set an alternate escape char for composition mode; this
## helps prevent command collision with ssh(1) which also uses
## the '~' character for session escapes:
# set escape char to "`" (backtick):
#set escape=`
 
## enable piping output of mailx cmds. In example, typing
## '|wc -w' gives word count for *body* of current msg:
set enable-pipes
 
# Set things to prompt for before sending:
set append ask autoprint
 
## Set indent prefix (for Replys); use with '~m':
set indentprefix="> "
 
## Set autograph string & alternate (use with '~a' & '~A'):
set sign='SDFuser / SDF Public Access UNIX'
set Sign='SDFuser of SDF'
 
## pipe html/text type messages thru lynx(1), the text
## web browser.  This makes reading html msgs easier:
set mime-decode-header mime-decode-message mime-decode-quote
set mime-body-text-html="+/usr/pkg/bin/lynx -force_html -dump -stdin"

Basic Use

The mail(1) manpage will explain basic usage; once mail(1) is running you can type help and list for basic help info and a listing of commands. Many commands can be abbreviated, i.e. ‘m’ for mailto, ‘d’ for delete, ‘p’ for print. To page through multiple screens of messages use z (down) and z - (up). A useful command is x which will quit without saving changes – handy if you've made several unintended changes, i.e. deleting a bunch of messages.

Composition

To compose a new message either launch mail(1) with mail someone@addr.foo or type m someone@addr.foo within mail(1). Any defined aliases can be substituted for an address or group of addresses. For example if alias mylist one@addr1 two@addr2 three@addr3 is defined then typing m mylist will send your message to all addresses to the right of “mylist”.

To reply to a message to a user from within mail(1) type R. This will put you in composition mode; to get help type ~? or “?” prefixed with whatever alternate escape character you've set (may be needed within secure shell sessions).

Some useful composition commands: ~m will quote the current message using the indentprefix character(s); ~e will launch the editor set in EDITOR; ~a will add the signature string assigned to sign. To finish your reply type either CNTL+D or a single “.” on a new line. If you've changed your mind and want to discard your reply type ~x (or ~q which will save the text to your ~/dead.letter file). To later retrieve the discarded contents within composition mode type ~r ~/dead.letter.

Tips & Tricks

1. If you'd rather not change the default composition mode escape character for mail(1) but are using secure shell (ssh) to connect to SDF you can add the following to your ~/.ssh/config file:

~homeuser/.ssh/config
# disable pty escapes:
EscapeChar none

This will disable PTY escapes completely; alternately you can choose a different escape character if needed.

2. The VISUAL editor variable can be set within ~/.mailrc to a shell script which invokes an interactive lynx(1) session on the current mail message (or several messages). This is useful for easilly following embedded URLs (lynx supports many protocols besides http/https such as gopher, finger, news and ftp). The following is a sample script:

~sdfuser/bin/veditor
#!/bin/sh -e
# veditor - for using lynx(1) as VISUAL editor in mail(1)
#
 
{ echo '<pre>'
  cat $* |egrep -m4 '^From:|^Date:|^To:|^Subject:'
  cat $* |sed '1,/^$/d'
  echo '</pre>'  ;} |lynx -force_html -stdin
 

To use current message just type v ; if in composition mode use ~v. It doesn't always look pretty but it's often enough for following a few links.

native_netbsd_mailx.txt · Last modified: 2024/09/06 05:55 by hc9