MAIL(1)                                                   MAIL(1)

     NAME
          mail, marshal, nedmail, send, aliasmail, smtp, smtpd,
          vwhois, filter, fs, biff, pop3 -  mail commands

     SYNOPSIS
          mail [ arg ... ]

          upas/marshal [ -t mime-type ] [ -[aA] attachment ] [ -s
          subject ] [ -r ] [ -x ] [ -# ] [ -n ] [ mailaddr ... ]

          upas/send [ -b ] [ -i ] [ -r ] [ -x ] [ -# ] [ -n ] [
          mailaddr ... ]

          upas/nedmail [ -c [dir] ] [ -r ] [ -f mailfile ] [ -s
          mailfile ]

          upas/fs [ -f mailbox ] [ -b ] [ -n ] [ -p ]

          upas/biff

          upas/filter [ -bh ] rcvr mailbox regexp file [ regexp file
          ]*

          upas/pop3

     DESCRIPTION
        Mail
          Mail is a shell script that invokes upas/nedmail when no
          recipients appear on the command line and upas/marshal oth-
          erwise.  All command line options are passed through.

        Sending mail
          Marshal builds a mail message from standard input and passes
          it to send for transmission or delivery.  It adds to the
          beginning of the message any headers in the file
          /mail/box/username/headers.  This allows the addition of
          personal headers like From: lines with a full name or a dif-
          ferent return address.  The message format is both RFC 822
          and MIME conformant, so marshal adds any required headers
          not already in the message.  Command line options direct
          marshal to add a subject line and append attachments.  The
          arguments to marshal are the addresses of the recipients.

          When running in a rio(1) window, marshal automatically puts
          the window into hold mode (see rio(1)); this means that the
          message can be edited freely, because nothing will be sent
          to marshal until the ESC key is hit to exit hold mode.

          The options are:

     Page 1                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          -afile   directs marshal to append file as a mime attach-
                   ment.  Unless explicitly specified by the -t
                   option, the type of the attachment is determined by
                   running the file(1) command.
          -Afile   is like -a but the message disposition is marked as
                   inline directing any mail reader to display the
                   attachment (if it can) when the mail message is
                   read.
          -ttype   sets the content type for the attachments from all
                   subsequent -a and -A options.
          -ssubject
                   adds a Subject: header line to the message if one
                   does not already exist.
          -#xnr    are all passed as command line options to the send
                   that marshal invokes.

          Send reads a message from standard input and disposes of it
          in one of four ways:

          +o  If mailaddr refers to a local mailbox, it appends it to
             the recipient's mailbox.

          +o  If mailaddr is remote, it queues the mail for remote
             delivery.

          +o  If the -r option is given and the mail is undeliverable,
             it returns the mail to the sender.

          +o  if the -r option is not given and the mail is undeliver-
             able, it appends the mail to
             /mail/box/username/dead.letter and prints a message to
             standard error.

          The file /mail/lib/rewrite determines exactly how to deliver
          or queue the mail.  The decision is based purely on the
          recipient address.

          The options are:

          -b  suppresses the addition of the To: line.
          -i  let the message input be terminated by a line containing
              only a period, for compatibility with old mailers.
          -x  do not send mail, but instead report the full mail
              address of the recipient.
          -#  do not send mail, but instead report what command would
              be used to send the mail.
          -r  input is via a pipe from another program.  Expect a From
              line at the start of the message to provide the name of
              the sender and timestamp.  This implies the -b option.

        Reading mail
          Nedmail edits a mailbox.  The default mailbox is

     Page 2                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          /mail/box/username/mbox.  The -f command line option speci-
          fies an alternate mailbox.  Unrooted path names are inter-
          preted relative to /mail/box/username.  If the mailfile
          argument is omitted, the name defaults to stored.

          The options are:

          -c dir       Create a mailbox.  If dir is specified, the new
                       mailbox is created in
                       /mail/box/username/dir/mbox.  Otherwise, the
                       default mailbox is created.
          -r           Reverse: show messages in first-in, first-out
                       order; the default is last-in, first-out.
          -f mailfile  Read messages from the specified file (see
                       above) instead of the default mailbox.
          -s mailfile  Read a single message file mailfile, as pro-
                       duced by fs, and treat it as an entire mailbox.
                       This is provided for use in plumbing rules; see
                       faces(1).

          Nedmail starts by reading the mail box, printing out the
          number of messages, and then prompting for commands from
          standard input.  Commands, as in ed(1), are of the form
          `[range] command [arguments]'.  The command is applied to
          each message in the (optional) range.

          The address range can be:

          address       to indicate a single message header
          address,address
                        to indicate a range of contiguous message
                        headers
          g/expression/ to indicate all messages whose headers match
                        the regular expression.
          g%expression% to indicate all messages whose contents match
                        the regular expression.

          The addresses can be:

          number        to indicate a particular message
          address.number
                        to indicate a subpart of a particular message
          /expression/  to indicate the next message whose header
                        matches expression
          %expression%  to indicate the next message whose contents
                        match expression
          empty or .    to indicate the current message
          -address      to indicate backwards search or movement

          Since messages in MIME are hierarchical structures, in
          nedmail all the subparts are individually addressable.  For
          example if message 2 contains 3 attachments, the attachments

     Page 3                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          are numbered 2.1, 2.2, and 2.3.

          The commands are:

          a args     Reply to all addresses in the To:, From:, and Cc:
                     header lines.  Marshal is used to format the
                     reply and any arguments the user specifies are
                     added to the command line to marshal before the
                     recipient.  The possibility of making a fool of
                     yourself is very high with this command.
          A args     Like a but with the message appended to the
                     reply.
          b          Print the headers for the next ten messages.
          d          Mark message to be deleted upon exiting nedmail.
          f          Append the message to the file
                     /mail/box/username/sendername where sendername is
                     the account name of the sender.
          h          Print the disposition, size in characters, and
                     header line of the message.
          help       Print a summary of the commands.
          m person ...
                     Forward the message as a mime attachment to the
                     named persons.
          M person ...
                     Like m but allow the user to type in text to be
                     included with the forwarded message.
          p          Print message. An interrupt stops the printing.
          r args     Reply to the sender of the message.  Marshal is
                     used to format the reply.  If and optional Args
                     are specified, they are added to the command line
                     to marshal before the recipient's address.
          R  args    Like r but with the original message included as
                     an attachment.
          rf         Like r but append the message and the reply to
                     the file /mail/box/username/sendername where
                     sendername is the account name of the sender.
          Rf         Like R but append the message and the reply to
                     the file /mail/box/username/sendername where
                     sendername is the account name of the sender.
          s mfile    Append the message to the specified mailbox.  If
                     mfile doesn't start with a `/', it is interpreted
                     relative to the directory in which the mailbox
                     resides.
          q          Put undeleted mail back in the mailbox and stop.
          EOT (control-D)
                     Same as q.
          w file     Same as s with the mail header line(s) stripped.
                     This can be used to save binary mail bodies.
          u          Remove mark for deletion.
          x          Exit, without changing the mailbox file.
          |command   Run the command with the message as standard
                     input.

     Page 4                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          !command   Escape to the shell to do command.
          =          Print the number of the current message.

          Here's an example of a mail session that looks at a summary
          of the mail messages, saves away an html file added as an
          attachment to a message and then deletes the message:

          % mail
          7 messages
          : ,h
          1        mul  4410  Jul 22 12:30  noone@madeup.net  "Add Up To 2
          1.1      txt  1413
          1.2      html  1966
          2        txt   504  Jul 22 11:43  jmk
          3        mul   784  Jul 20 09:05  presotto
          3.1      txt   136
          3.2      txt   323  Jul 12 16:16  presotto
          4        txt   822  Jul 11 09:23  xxx@yyy.net  "You don't call, you don
          5        txt   193   Jul 6 16:55  presotto
          6        txt   529   May 7 19:42  jmk
          7        txt   798   Sep 2 13:55  howard
          : 1.2w /tmp/northwest.html
          !saved in /tmp/northwest.html
          1.2: d
          1: q
          !1 message deleted
          %

          Notice that the delete of message 1.2 deleted the entire
          message and not just the attachment.

        Aliasmail
          Aliasmail expands mail aliases, its arguments, according to
          alias files.  Each line of an alias file begins with # (com-
          ment) or with a name.  The rest of a name line gives the
          expansion.  The expansion may contain multiple addresses and
          may be continued to another line by appending a backslash.
          Items are separated by white space.

          In expanding a name, the sender's personal alias file
          /mail/box/username/names is checked first.  Then the system
          alias files, listed one per line in /mail/lib/namefiles, are
          checked in order.  If the name is not found, the expansion
          is taken to be local!name.  Under the -f option, alias files
          listed in /mail/lib/fromfiles are consulted instead, and the
          domain part only of the expansion is printed.

        Mailboxes
          Incoming mail for a user username is put in the file
          /mail/box/username/mbox unless either the file
          /mail/box/username/forward or /mail/box/username/pipeto
          exists.  The mailbox must have append-only and exclusive-

     Page 5                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          access mode (see chmod(1)). A user must create his or her
          own mailbox using the -c option of nedmail. Mailboxes are
          created writable (append-only) but not readable by others.

        Forwarding
          If the file /mail/box/username/forward exists and is read-
          able by everyone, incoming mail will be forwarded to the
          addresses contained in the first line of the file.  The file
          may contain multiple addresses.  Forwarding loops are caught
          and resolved by local delivery.

        Filtering
          If the file /mail/box/username/pipeto exists and is readable
          and executable by everyone, it will be run for each incoming
          message for the user.  The message will be piped to it
          rather than appended to his/her mail box.  The file is run
          as user none with arguments of the resolved address of
          username (e.g.  local!presotto) and his/her mail box name.

          Filter provides simple mail filtering.  The first two argu-
          ments are the recipient's address and mailbox, i.e., the
          same arguments provided to pipeto.  The remaining arguments
          are all paired; a regular expression and a file name.  With
          no flags, the sender's address is matched against each regu-
          lar expression starting with the first.  If the expression
          matches, then the message is delivered to the file whose
          name follows the expression.  The file must be world writ-
          able and should be append only.  A message that matches none
          of the expressions is delivered into the user's standard
          mail box.  The flags are:

          h    the regular expression is matched against the message
               header rather than the address.

          b    the regular expression is matched against both the
               header and the body of the message.

          For example, to delete any messages of precedence bulk,
          place in your pipeto file:
          /bin/upas/filter -h $1 $2 'Precedence: bulk' /dev/null

        Mime File system
          Fs is a user level file system that reads mailboxes and pre-
          sents them as a file system.  A user normally starts fs in
          his/her profile after starting plumber(4) and before start-
          ing a window system, such as rio(1) or acme(1). The file
          system is used by nedmail and acme(1)'s mail reader to parse
          messages.  Fs also generates plumbing messages used by biff
          and faces(1) to provide mail announcements.

          The mailbox itself becomes a directory under /mail/fs.  Each
          message in the mailbox becomes a numbered directory in the

     Page 6                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          mailbox directory, and each attachment becomes a numbered
          directory in the message directory.  Since an attachment may
          itself be a mail message, this structure can recurse ad nau-
          seam.

          Each message and attachment directory contains the files:

          body          the message minus the RFC822 style headers
          cc            the address(es) from the CC: header
          date          the date in the message, or if none, the time
                        of delivery
          digest        an SHA1 digest of the message contents
          disposition   inline or file
          filename      a name to use to file an attachment
          from          the from address in the From: header, or if
                        none, the address on the envelope.
          header        the RFC822 headers
          info          described below, essentially a summary of the
                        header info
          inreplyto     contents of the in-reply-to: header
          mimeheader    the mime headers
          raw           the undecoded MIME message
          rawbody       the undecoded message body
          rawheader     the undecoded message header
          replyto       the address to send any replies to.
          subject       the contents of the subject line
          to            the address(es) from the To: line.
          type          the MIME content type
          unixheader    the envelope header from the mailbox

          The info file contains the following information, one item
          per line.  Lists of addresses are single space separated.

          sender address
          recipient addresses
          cc addresses
          reply address
          envelope date
          subject
          MIME content type
          MIME disposition
          filename
          SHA1 digest
          bcc addresses
          in-reply-to: contents
          RFC822 date
          message senders
          message id
          number of lines in body

          Deleting message directories causes the message to be

     Page 7                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          removed from the mailbox.

          The mailbox is reread and the structure updated whenever the
          mailbox changes.  Message directories are not renumbered.

          The file /mail/fs/ctl is used to direct fs to open/close new
          mailboxes or to delete groups of messages atomically.  The
          messages that can be written to this file are:

          open path mboxname  opens a new mailbox.  path is the file
                              to open, and mboxname is the name that
                              appears under /mail/fs.
          close mboxname      close mboxname. The close takes affect
                              only after all files open under
                              /mail/fs/mboxname have been closed.
          delete mboxname number ...
                              Delete the messages with the given num-
                              bers from mboxname.

          The options are:

          -ffile   use file as the mailbox instead of the default,
                   /mail/box/username/mbox.
          -b       stands for biffing.  Each time new mail is
                   received, a message is printed to standard output
                   containing the sender address, subject, and number
                   of bytes.  It is intended for people telnetting in
                   who want mail announcements.
          -n       Don't open a mailbox initially.  Overridden by -f.
          -p       turn off plumbing.  Unless this is specified, fs
                   sends a message to the plumb port, seemail, from
                   source mailfs for each message received or deleted.
                   The message contains the attributes
                   sender=<contents of from file>, filetype=mail,
                   mailtype=deleted or new, and length=<message length
                   in bytes>.  The contents of the message is the full
                   path name of the directory representing the mes-
                   sage.
          -s       causes fs to put itself in /srv with a name of the
                   form /srv/upasfs.user.
          -m       specifies a mount point other than /mail/fs.

          Fs will exit once all references to its directory have dis-
          appeared.

        Mail Announcements
          Biff is the textual equivalent of faces(1). It listens to
          plumbing messages from fs and for each new message prints to
          standard output a line containing the sender address, sub-
          ject, and number of bytes.  It exists for people without
          graphics capability or with screens too small to dedicate
          the space faces(1) requires.  It forks to place itself in

     Page 8                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

          the background.

        Remote delivery
          Smtp sends the mail message from standard input to the users
          rcpt-list on the host at network address address using the
          Simple Mail Transfer Protocol.  The return address of the
          mail will contain the local system name from the environment
          variable sysname and the user sender. The -h option uses
          host as the local system name; it may be fully-qualified or
          not.  If .domain is given, it is appended to the end of the
          system name.  The -f option just prints out the converted
          message rather than sending it to the destination.  The -g
          option specifies a gateway system to pass the message to if
          smtp can't find an address or MX entry for the destination
          system.  The -d option turns on debugging output to standard
          error.

          Smtpd receives a message using the Simple Mail Transfer Pro-
          tocol.  Standard input and output are the protocol connec-
          tion.

          The options are:

          -d         turns on debugging output to standard error.

          -r         turns on forward DNS validation of non-trusted
                     sender address.

          -f         prevents relaying from non-trusted networks.

          -n tcp-directory
                     specifies the name of the network directory
                     assigned to the incoming connection.  This is
                     used to determine the peer IP address.  If this
                     flag is not specified, the peer address is deter-
                     mined using standard input.

          -h domain  specifies the receiving domain.  If this flag is
                     not specified, the receiving domain is inferred
                     from the host name.

          -s         causes copies of blocked messages to be saved in
                     a sub-directory of /mail/queue.dump.

          -k IP address
                     causes connections from the host at IP address to
                     be dropped at program startup.  Multiple
                     addresses can be specified with several -k
                     options.  This option should be used carefully;
                     it is intended to lessen the effects of denial of
                     service attacks or broken mailers which continu-
                     ally connect.  The connections are not logged and

     Page 9                       Plan 9            (printed 11/22/24)

     MAIL(1)                                                   MAIL(1)

                     the remote system is not notified via the proto-
                     col.

          Smtpd is normally run by a network listener such as
          listen(8). Most of the command line options are more conve-
          niently specified in the smtpd configuration file stored in
          /mail/lib/smtpd.conf.

        Mail server
          Pop3 is a rudimentary POP3 server that uses APOP for authen-
          tication.  It predates upas/fs and does not use it.  It will
          soon be replaced by one that uses upas/fs. See also the
          IMAP4 server described in ipserv(8).

     FILES
          /sys/log/mail            mail log file
          /mail/box/*              mail directories
          /mail/box/*/mbox         mailbox files
          /mail/box/*/forward      forwarding address(es)
          /mail/box/*/pipeto       mail filter
          /mail/box/*/L.reading    mutual exclusion lock for multiple
                                   mbox readers
          /mail/box/*/L.mbox       mutual exclusion lock for altering
                                   mbox
          /mail/box/*/dead.letter  unmailable text
          /mail/box/*/names        personal alias files
          /mail/lib/rewrite        rules for handling addresses
          /mail/lib/namefiles      lists files to search for aliases
                                   in
          /lib/face/48x48x?        directories of icons for seemail

     SOURCE
          /rc/bin/mail
          /sys/src/cmd/upas  source for commands in /bin/upas
          /sys/src/cmd/faces
          /rc/bin/vwhois

     SEE ALSO
          face(6), rewrite(6) ipserv(8)

     BUGS
          Nedmail truncates long headers for searching.

          Biff and the -b option of fs perform the same function but
          in slightly different environments.  The duality is confus-
          ing.  The -b option exists because starting both fs and biff
          in a Telnet session results in a number of processes that
          don't die when the session is terminated; the plumber(4) is
          held open by fs and biff still having it mounted, while fs
          is held open by biff which is blocked waiting for plumbing
          input.

     Page 10                      Plan 9            (printed 11/22/24)