This is an old revision of the document!
Table of Contents
An Introduction to Various BSD mailx style E-mail Clients on SDF
History
In the beginning.. there was mail, which was included in Unix 1st Edition in 1971 according to the ancient texts (manuals). At this time, Unix had no remote communication facility at all, so mail would simply write to other users' files on a single machine. As systems began to be networked mailx came on the scene with expanded features. Eventually the two merged; these days mail and mailx are one and the same program and enjoy near-unversal presence across all flavors of Unix and Linux. For a bit more mailx history see the Heirloom Project.
Getting Started
One of the great features of mailx is it behaves like most traditional Unix commands; you can pipe the output of other commands to it or use it in a shell script or crontab. With just the default settings a user should be able to send a message to themselves or another account on the local system like so:
$ mailx //localuser//
The sender will generally be prompted to enter a Subject: after which they simply type their message then press CTRL+D
to signal end of file (EOF) and off it goes.
To further automate sending simple messages the subject and an input file can generally be specified on the command line like so:
$ mailx -s "simple test" //some_user// < myfile
Most mailx implementations allow multiple addressees as well as CC / BCC recipients to be specified on the command line which makes it's fairly easy to automate the sending of regular broadcast-type emails.
Using mailx on SDF
There are many Mail User Agents (MUA) on SDF including at least 3 flavors of mailx:
- mail,Mail,mailx – the native NetBSD mailx with MIME extensions
- heirloom-mailx – formerly nail; supports MIME + POP3, IMAP & SMTP (not actively developed)
- s-nail/s-mailx – an actively developed fork of heirloom-mailx
Most likely the default SDF shell PATH
variable will give the native tools precedence over those installed via a package manager. This means typing mailx
will mostl likely run /usr/bin/mailx
(native mailx), not /usr/pkg/bin/mailx
(heirloom-mailx). A simple way to check:
$ which mailx /usr/bin/mailx => this shell checks native tool locations first
Similarly for man(1)
, the manpage reader; below is how to read each:
$ man mailx # native mailx documentation $ man -S pkg mailx # heirloom-mailx documentation $ man s-nail # s-mailx documentation
Users on the SDF cluster will find additional documentation under /usr/share/
:
- Mail Reference Manual –
/usr/share/doc/reference/ref1/mail/mail.txt
- Mail Command Reference –
/usr/share/misc/mail.help
- Mail Tilde Command Ref –
/usr/share/misc/mail.tildehelp
To read use any pager like more or less, or even the lynx browser.
Basic mailx Usage
Each of the 3 mailx programs are sufficently different that beyond the very basics they need to be covered separately in this tutorial. That said, the following should work on all implementations:
- headers [msg range]
- Reply/reply [msg]
- mail [recepient]
- file/folder [mail_folder]
- folders
- delete [msg range]
- save [msg range] [folder]
playground:NetBSD Mailx (mail)
playground:Heirloom Mailx (nail)] [[playground:native Mail|playground:S-mailx (s-nail)