mail - implementation of Berkeley mail(1)
mail [-f mailbox]
mail [-s subject] [-c cc-addrs] [-b bcc-addrs] to-addr [..toaddr..]
When called without command-line options (except -f) mail allows the user to interactively send mail, and manage a mail folder. Otherwise, mail allows the user to send outgoing E-mail to recipients.
When run interactively, the mail folder ~/mbox is used. If the home directory cannot be determined, ./mbox is assumed. This can be overridden with the -f option.
mail accepts the following options
- -f mailbox
Specifies a mail folder to use.
- -s subject
Specify a subject for the mail message.
- -c cc-addrs
A comma-separated list of addresses to be copied to on the mail message.
- -b bcc-addrs
A comma-separated list of addresses to be copied to on the mail message, without appearing in the headers.
E-Mail destination addresses. You may not be notified if mail fails to deliver to the address properly.
In the list below, "msg" indicates a message list. Acceptable values are comma or space separated lists, ranges (i.e. 1-5) or single digits. Special values are "$" (end of list) and * (all messages). If messages are unspecified, the current message is used. "path" indicates a filename argument. "addr" indicates a mail message address list (comma or space separated).
Read message number.
Execute the "command" with the command interpreter.
- copy msg path
Copy indicated messages (msg) to filename at path. co is an alias for this command.
- delete msg
Delete indicated messages. d is an alias for this command.
Exit the mail program saving no changes to the mailbox. x is an alias for this command.
- from msg
Display the headers from the specified messages. f is an alias for this command.
- headers msg
Display a brief list of headers from the messages. h is an alias for this command.
- hold msg
Mark messages as unread. ho,preserve are aliases for this command.
- mail addr
Send a mail message to addr. m is an alias for this command.
Print the next message in sequence. n is an alias for this command.
- print msg
Print the specified mail message. p,CR are aliases for this command.
Exit the mail program. The (possibly) edited mailbox is re-written to its original file. See Bugs. q is an alias for this command.
Reply to the original sender of msg. r is an alias for this command.
- Reply msg
Reply to the original sender, and all visible recipients of msg. R is an alias for this command.
- save msg path
Save msg into the file specified at path. If the file exists, it is appended. s is an alias for this command.
Start an interactive bourne shell. (This does not work under Win32). sh is an alias for this command.
Display the first few lines of the current mail message.
- undelete msg
Mark as undeleted any specified mail messages. u is an alias for this command.
- unread msg
Mark as unread any specified mail messages. U is an alias for this command.
- visal msg
Invoke the visual editor (specified in $VISUAL, or /usr/bin/vi) on the indicated messages. Re-read those messages in afer the editing session. v is an alias for this command.
- write msg path
Write the bodies of the indicated messages to path. w is an alias for this command.
When sending a mail message (commands mail, reply or Reply) a primitive line-mode editor is used to get the body of the mail message, and possibly change any header options. During the editing session, special commands may be used when typed at the beginning of the line.
To send the message, send an EOF character or a "." on a line by itself.
Change message subject to subject.
Quit the message editor. No changes are made, no message is sent.
Add the addrs to the CC list for the message
Add the addrs to the BCC list for the message
Add the addrs to the To: list for the message
Read the specified messages into the current message at the end.
Read the specified messages into the current message at the end, indenting each line with the sequence "> ".
Read the contents of file into the message.
Invoke the visual editor on the message. When the user is done editing the message, read the message back in, and continue editing at the end.
Numerous. Mostly lack of refinement in the implementation, any of which can be fixed without hassle, I'm sure.
Many (many, many..) features left unimplemented. Command-line, commands and editing functions have all been decimated. I only implemented what I thought was useful. BSD mail had many years to develop its many tentacles. I don't have that kind of patience.
Keeping track of the "current" message in the mail folder is sloppy.
Screen length is assumed to be 23 characters. Width is 79.
Argument parsing doesn't ensure sane (and legal) combinations.
There is no file locking. Of anything. You wanna re-write the mailbox and there's local delivery going on? Fine. Have fun. mail will refuse to write back a mailbox whose size has changed however...
mail doesn't act as a Local Delivery Agent.
mail's method of picking through mail message headers to find from, to and cc addresses violates several FAQ's, RFC's, and is void where prohibited. Also easy to fix, I simply ran out of patience. See the _extract method in the message class if you're adventuresome.
To perform delivery, mail searches for
$LOGNAMEin your environment to see who you are (for a From address). It then searches for an SMTP agent on localhost. Not finding that, it wants $RELAYHOST set to your SMTP relaying host name. Your reply address is taken from $REPLYADDR or your system's environment. Whichever is easier. Win32 systems, be prepared to setup your environment properly for this to work!
...speaking of SMTP... mail talks directly to SMTP instead of using a more sane method like Mail::Mailer. This was done so that PPT mail(1) could remain "pure" and un-encumbered by external modules.
This code is not "use strict" safe. Although there's not much keeping it from being "use strict" safe. Use of package-based variables will probably get me thumped from Tom.
The Perl implementation of mail was written by Clinton Pierce, email@example.com.
This program is Copyright 1999, by Clinton Pierce.
Freely redistributable under the Perl Artistic License.