[AIX 네트워크 관리 2] 메일 (1) 메일 시스템, 사용자 에이전트, 메일 읽기·정리

핵심 정리

  • 메일 시스템은 사용자 인터페이스(mail, MH의 mhmail), 메시지 라우팅 프로그램(sendmail 데몬, /etc/mail/sendmail.cf·/etc/mail/aliases 사용), 배달 프로그램(메일러)으로 이루어집니다.
  • sendmail은 로컬 메일을 bellmail로 넘겨 /var/spool/mail의 시스템 메일함에 붙이고, UUCP 링크는 BNU로, TCP/IP는 SMTP로 원격 시스템에 보냅니다.
  • mail과 mh는 메일 저장 방식이 서로 맞지 않으므로 둘 가운데 하나를 골라 씁니다.
  • 저장 위치: 시스템 메일함 /var/spool/mail/사용자, 읽은 메일이 가는 개인 메일함 $HOME/mbox, 쓰다 중단한 메일 $HOME/dead.letter(매번 덮어씀), 폴더(.mailrc의 set folder=디렉터리).
  • 메일함 하위 명령: h(목록), z/z+/z-(넘기기), f(머리글 필터), t/p(읽기), n/-(다음·이전), d/u(삭제·되살리기), s(머리글과 함께 저장), w(본문만 저장), folder(현재 메일함), q(저장하고 끝냄), x(바꾸지 않고 끝냄).
항목 내용
버전 AIX 5.3, AIX 6.1 (내용이 거의 같음)
원문 Networks and communication management — 5.3판 920쪽, 6.1판 921쪽
파일 /etc/mail/sendmail.cf, /etc/mail/aliases, /var/spool/mail/사용자, $HOME/mbox, $HOME/dead.letter, $HOME/.mailrc
관련 명령어 mail, mhmail, bellmail, sendmail

메일 기능은 같은 시스템의 사용자나, 네트워크로 연결된 여러 시스템의 사용자와 전자 우편(e-mail)을 주고받는 방법을 제공합니다. 여기서는 메일 시스템, 표준 메일 사용자 인터페이스, IMAP(Internet Message Access Protocol), POP(Post Office Protocol)를 설명합니다.

메일 시스템은 사용자 인터페이스, 메시지 라우팅 프로그램, 메시지 배달 프로그램(메일러)으로 이루어진 네트워크 간 메일 배달 기능입니다. 같은 호스트의 사용자 사이, 호스트 사이, 네트워크 경계를 넘어 메시지를 중계합니다. 받는 호스트에 알맞은 형식이 되도록 메시지 머리글을 조금 고치기도 합니다.

메일 사용자 인터페이스는 사용자가 다른 사용자와 메시지를 만들고, 보내고, 받게 합니다. 메일 시스템은 mail과 mhmail 두 가지 사용자 인터페이스를 제공합니다. mail 명령은 모든 UNIX 시스템에 있는 표준 메일 사용자 인터페이스입니다. mhmail 명령은 MH(Message Handler) 사용자 인터페이스로, 숙련된 사용자를 위해 기능을 늘린 메일 사용자 인터페이스입니다.

메시지 라우팅 프로그램은 메시지를 목적지로 보냅니다. 메일 시스템의 메시지 라우팅 프로그램은 sendmail이며, 기본 운영 체제(BOS)의 일부로 BOS와 함께 설치됩니다. sendmail은 /etc/mail/sendmail.cf 파일과 /etc/mail/aliases 파일의 정보로 필요한 라우팅을 하는 데몬입니다.

sendmail 명령은 목적지까지의 경로 유형에 따라 서로 다른 메일러로 메시지를 배달합니다.

text
          Mail          MH
             \        /
              sendmail
          /      |       \
   bellmail     BNU       SMTP
      |          |          |
local mailbox  UUCP link  TCP/IP link
                 |          |
          remote mailbox  remote mailbox

그림 2. sendmail 명령이 쓰는 메일러(원문 그림을 글자로 다시 그림)

그림처럼 다음과 같이 배달합니다.

  • 로컬 메일을 배달할 때 sendmail은 메시지를 bellmail 프로그램으로 보냅니다. bellmail은 메시지를 /var/spool/mail 디렉터리에 있는 사용자의 시스템 메일함에 덧붙여 모든 로컬 메일을 배달합니다.
  • UUCP(UNIX-to-UNIX Copy Program) 링크로 메일을 배달할 때 sendmail은 BNU(Basic Network Utilities)로 메시지를 보냅니다.
  • TCP/IP로 라우팅되는 메일을 배달할 때 sendmail 명령은 원격 시스템과 TCP/IP 연결을 맺은 다음 SMTP(Simple Mail Transfer Protocol)로 메시지를 원격 시스템에 전송합니다.
영어 원문

Mail management

The mail facility provides a method for exchanging electronic mail (e-mail) with users on the same system or on multiple systems connected by a network. The mail system, the standard mail user interface, the Internet Message Access Protocol (IMAP), and the Post Office Protocol (POP) are described here.

The mail system is an internetwork mail delivery facility that consists of a user interface, a message routing program, and a message delivery program (or mailer). The mail system relays messages from one user to another on the same host, between hosts, and across network boundaries. It also performs a limited amount of message-header editing to put the message into a format that is appropriate for the receiving host.

A mail user interface enables users to create and send messages to, and receive messages from, other users. The mail system provides two user interfaces, mail and mhmail. The mail command is the standard mail user interface available on all UNIX systems. The mhmail command is the Message Handler (MH) user interface, an enhanced mail user interface designed for experienced users.

A message routing program routes messages to their destinations. The mail system message routing program is the sendmail program, which is part of the Base Operating System (BOS) and is installed with BOS. The sendmail program is a daemon that uses information in the /etc/mail/sendmail.cf file, the /etc/mail/aliases file to perform the necessary routing.

Depending on the type of route to the destination, the sendmail command uses different mailers to deliver messages.

This illustration is a type of top-down organizational chart with Mail and MH at the top. Branching from them are bellmail, BNU and SMTP. Underneath the previous level are local mailbox, UUCP link, and TCP/IP link respectively. Beneath UUCP link is remote mailbox and under TCP/IP link is remote mailbox.

As the figure illustrates:

  • To deliver local mail, the sendmail program routes messages to the bellmail program. The bellmail program delivers all local mail by appending messages to the user's system mailbox, which is in the /var/spool/mail directory.

  • To deliver mail over a UNIX-to-UNIX Copy Program (UUCP) link, the sendmail program routes messages using Basic Network Utilities (BNU).

  • To deliver mail routed through Transmission Control Protocol/Internet Protocol (TCP/IP), the sendmail command establishes a TCP/IP connection to the remote system then uses Simple Mail Transfer Protocol (SMTP) to transfer the message to the remote system.

메일 사용자 에이전트 프로그램

메일 시스템을 쓰려면 먼저 사용자 에이전트 프로그램을 골라야 합니다. mail 프로그램(mail), 메시지 처리기(mh), bellmail 명령 가운데 고를 수 있습니다.

사용자 에이전트 프로그램은 메일을 만들고, 받고, 보내고, 정리하는 기능을 줍니다. 그 밖에 전송 에이전트 프로그램 sendmail이 필요합니다. sendmail은 다른 시스템이나 패키지에서 들어오는 메일을 나누어 주고, 나가는 메일을 하나하나 나누어 하나 이상의 원격 시스템에 있는 비슷한 프로그램으로 전송합니다.

참고: mail과 mh 프로그램은 메일을 저장하는 방식이 서로 맞지 않으므로 둘 가운데 하나만 골라야 합니다.

영어 원문

Mail user-agent programs

Before you can use the mail system, you must select a user-agent program. You can choose a mail program (mail), message handler (mh), or the bellmail command.

A user-agent program provides facilities for creating, receiving, sending, and filing mail. In addition, you need a transport-agent program, sendmail, which distributes incoming mail from other systems or packages and distributes each outgoing mail item and then transmits it to a similar program in one or more remote systems.

Note: The mail and mh programs are incompatible in the way they store mail; you must choose one mail handler or the other.

mail 프로그램 인터페이스

mail 프로그램은 로컬 네트워크 사용자와 원격 시스템 사용자 모두와 메일을 주고받는 사용자 인터페이스를 줍니다.

메일 메시지는 편집기로 입력한 텍스트일 수도 있고 ASCII 파일일 수도 있습니다. 입력한 메시지나 파일 말고도 다음을 보낼 수 있습니다.

종류 설명
시스템 메시지(system message) 시스템이 갱신되었음을 사용자에게 알립니다. 방송(broadcast) 메시지와 비슷하지만 로컬 네트워크에만 보냅니다.
비밀 메일(secret mail) 기밀 정보를 보낼 때 씁니다. 비밀 메일 메시지는 암호화되며, 받는 사람이 암호를 입력해야 읽을 수 있습니다.
휴가 메시지(vacation message) 내가 휴가 중임을 알립니다. 내가 없는 동안 시스템이 메일을 받으면 보낸 쪽으로 휴가 중이라는 메시지를 돌려보냅니다. 휴가 중에 받은 메일은 전달(forward)할 수도 있습니다.

mail 하위 명령으로 메일을 받을 때는 다음을 할 수 있습니다.

  • 메일을 시스템 메일함에 그대로 둡니다.
  • 메일을 읽고 지웁니다.
  • 메일을 전달합니다.
  • 메일에 주석을 답니다.
  • 메일을 개인 메일함(mbox)에 저장합니다.
  • 메일을 내가 만든 폴더에 저장합니다.
  • 메일과 메일 메시지의 갈 곳을 정하는 별칭 파일이나 배포 파일을 만들고 관리합니다.

sendmail은 자동으로 설치됩니다.

mail 프로그램에 관한 자세한 내용은 메일 기능 절을 봅니다.

영어 원문

Mail program interface

The mail program provides you with a user interface to handle mail to and from both a local network user and a remote system user.

A mail message can be text, entered using an editor, or an ASCII file. In addition to a typed message or a file, you can send: bellmail

local mailbox Mail MH

BNU SMTP

UUCP link TCP/IP link

remote mailbox remote mailbox sendmail

Figure 2. Mailers used by the sendmail command

  • system message — Informs users the system has been updated. A system message is similar to a broadcast message but is sent on the local network only.
  • secret mail — Used to send classified information. A secret mail message is encrypted. The recipient must enter a password to read it.
  • vacation message — Informs users you are on vacation. When your system receives mail in your absence, it sends a message back to the origin. The message states you are on vacation. Any mail you receive while on vacation can also be forwarded.

When you receive mail using the mail subcommands, you can:

  • Leave the mail in the system mailbox.

  • Read and delete the mail.

  • Forward the mail.

  • Add comments to the mail.

  • Store the mail in your personal mailbox (mbox).

  • Store the mail in a folder you have created.

  • Create and maintain an alias file or a distribution file, which directs the mail and mail messages.

The installation of sendmail is automatic.

For more information about the mail program, refer to Mail functions.

메시지 처리기(mh)

mh 프로그램은 메일 처리 기능 하나하나를 명령줄에서 바로 할 수 있게 하는 명령의 모음입니다.

이 명령들은 mail의 하위 명령보다 기능 범위가 넓습니다. 또 명령 프롬프트가 보이면 언제든 명령을 낼 수 있으므로, 메일을 만들고 받은 메일을 처리할 때 더 강력하고 유연합니다. 예를 들어 같은 셸 안에서 메일 메시지를 읽고, 파일을 찾거나 프로그램을 실행해 해결책을 찾고, 메시지에 답할 수 있습니다.

mh 프로그램은 다음 명령으로 메시지를 만들고, 배포하고, 받고, 보고, 처리하고, 저장하게 합니다.

명령 설명
ali 메일 별칭과 그 주소를 나열합니다.
anno 메시지에 주석을 답니다.
ap 주소를 해석하고 다시 서식화합니다.
burst 다이제스트(digest)를 낱낱의 메시지로 풉니다.
comp 메시지를 만들거나 고치는 편집기를 시작합니다.
dist 메시지를 다른 주소로 다시 배포합니다.
dp 날짜를 해석하고 다시 서식화합니다.
folder 폴더와 메시지를 고르고 나열합니다.
folders 메일 디렉터리의 모든 폴더와 메시지를 나열합니다.
forw 메시지를 전달합니다.
inc 새 메일을 폴더로 들여옵니다.
mark 메시지 시퀀스를 만들고, 고치고, 표시합니다.
mhl 메시지의 서식화된 목록을 만듭니다.
mhmail 메일을 보내거나 받습니다.
mhpath 메시지와 폴더의 전체 경로 이름을 출력합니다.
msgchk 메시지가 있는지 확인합니다.
msh 메시지 처리기(mh) 셸을 만듭니다.
next 다음 메시지를 보여 줍니다.
packf 폴더의 내용을 파일 하나로 압축합니다.
pick 내용으로 메시지를 고르고 시퀀스를 만들거나 고칩니다.
prev 이전 메시지를 보여 줍니다.
refile 폴더 사이에 파일을 옮깁니다.
repl 메시지에 답장합니다.
rmf 폴더와 그 안의 메시지를 지웁니다.
rmm 메시지를 활성 상태에서 뺍니다.
scan 메시지마다 한 줄씩 훑어볼 수 있는 목록을 만듭니다.
send 메시지를 보냅니다.
show 메시지를 보여 줍니다.
sortm 메시지를 정렬합니다.
vmh mh 명령과 함께 쓰는 시각 인터페이스를 시작합니다.
whatnow 초안 처리를 위한 프롬프트 인터페이스를 시작합니다.
whom mh 주소를 다룹니다.

mh 명령에 관한 자세한 내용은 Commands Reference 3권을 봅니다.

영어 원문

Message handler (mh)

The mh program is a collection of commands that enables you to perform each mail processing function directly from the command line.

These commands provide a broader range of function than the subcommands of mail. Also, because the commands can be issued at any time the command prompt is displayed, you gain power and flexibility in creating mail and in processing received mail. For example, you can read a mail message, search a file or run a program to find a particular solution, and answer the message, all within the same shell.

The mh program enables you to create, distribute, receive, view, process, and store messages using the following commands:

  • ali — Lists mail aliases and their addresses.
  • anno — Annotates messages.
  • ap — Parses and reformats addresses.
  • burst — Explodes digests into messages.
  • comp — Starts an editor for creating or modifying a message.
  • dist — Redistributes a message to additional addresses.
  • dp — Parses and reformats dates.
  • folder — Selects and lists folders and messages.
  • folders — Lists all folders and messages in the mail directory.
  • forw — Forwards messages.
  • inc — Incorporates new mail into a folder.
  • mark — Creates, modifies, and displays message sequences.
  • mhl — Produces a formatted listing of messages.
  • mhmail — Sends or receives mail.
  • mhpath — Prints full path names of messages and folders.
  • msgchk — Checks for messages.
  • msh — Creates a mail handler (mh) shell.
  • next — Shows the next message.
  • packf — Compresses the contents of a folder into a file.
  • pick — Selects messages by content and creates and modifies sequences.
  • prev — Shows the previous message.
  • refile — Moves files between folders.
  • repl — Replies to a message.
  • rmf — Removes folders and the messages they contain.
  • rmm — Removes messages from active status.
  • scan — Produces a one-line-per-message scannable listing.
  • send — Sends a message.
  • show — Shows messages.
  • sortm — Sorts messages.
  • vmh — Starts a visual interface for use with mh commands.
  • whatnow — Starts a prompting interface for draft disposition.
  • whom — Manipulates mh addresses.

For more information on mh commands, refer to the Commands Reference, Volume 3.

bellmail 명령

bellmail 명령은 원래의 AT&T UNIX 메일 명령입니다. 같은 시스템의 사용자와, BNU(UUCP라고도 함)로 접근할 수 있는 원격 시스템의 사용자에게 메일을 처리합니다.

이 프로그램들은 전화 접속(dialup)이나 전용 점대점 통신 회선으로 연결된 시스템의 네트워크만 지원합니다. 명령은 셸을 열며, 그 하위 명령으로 다음을 할 수 있습니다.

  • 표준 입력(직접 입력하거나 기존 파일에서 리디렉션)에서 데이터를 받아, 하나 이상의 주소(명령의 인수로 줌)와 시각을 더한 다음, 받는 사람마다 시스템 메일함 파일(/var/spool/mail/UserID)에 사본을 덧붙입니다.
  • 시스템 메일함 파일에서 메일을 읽습니다.
  • 메일을 개인 메일함 파일($HOME/mbox)이나 지정한 파일에 덧붙입니다.
  • BNU로 다른 시스템의 사용자에게 메일을 보냅니다.
  • 시스템 메일함 파일 맨 앞에 .forward 문을 넣어 시스템 메일함의 모든 메일을 다른 시스템의 메일함으로 자동으로 돌립니다.

그러나 이 메일 처리기를 제대로 쓰려면 UNIX 사용자로서 어느 정도 숙련되어 있어야 합니다. 자세한 내용은 Commands Reference의 bellmail 명령을 봅니다.

영어 원문

bellmail command

The bellmail command is the original AT&T UNIX mail command, which handles mail for users on the same system and also for users on remote systems that can be accessed by means of Basic Network Utilities (BNU), sometimes known as the UNIX-to-UNIX Copy Program (UUCP).

These programs support only networks of systems connected by dialup or leased point-to-point communication lines. The command opens a shell whose subcommands allow you to:

  • Take data from standard input (typed in or redirected from an existing file), add one or more addresses (supplied as arguments to the command itself) and a timestamp, then append a copy to each addressee's system mailbox file (/var/spool/mail/UserID).

  • Read mail items from your system mailbox file.

  • Append mail items to your personal mailbox file ($HOME/mbox) or to a specified file.

  • Send mail using BNU to a user on another system.

  • Automatically redirect all mail from your system mailbox to one on another system by adding a .forward statement to the beginning of your system mailbox file.

However, you must have some skill as a UNIX user before you can make full use of this mail handler. For more information, refer to the bellmail command in the Commands Reference, Volume 1.

메일 기능

mail 프로그램의 기능을 소개합니다.

mail 프로그램으로 로컬이나 원격 시스템의 사용자와 메일을 받고, 만들고, 보낼 수 있습니다.

영어 원문

Mail functions

The features of the mail program are introduced here.

The mail program enables you to receive, create, and send mail to users on a local or remote system.

메일 저장

메일은 상황에 따라 여러 방식으로 저장됩니다.

내 주소로 메일이 오면 메일 전용 시스템 디렉터리에 저장됩니다. 이 시스템 디렉터리에는 로컬 시스템의 사용자마다 파일이 하나씩 있습니다. 내가 메일을 처리할 때까지 이 디렉터리가 메일을 보관합니다.

시스템 메일함

시스템 메일함은 우체국 사서함과 비슷합니다. 우체국은 사서함 주인 앞으로 온 편지를 그 사서함에 넣습니다.

마찬가지로 시스템 메일함은 특정 사용자에게 오는 메시지가 배달되는 파일입니다. 메일이 왔을 때 파일이 없으면 만들어지고, 메시지가 모두 지워지면 파일도 지워집니다.

시스템 메일함은 /var/spool/mail 디렉터리에 있습니다. 시스템 메일함마다 연결된 사용자 ID가 이름이 됩니다. 예를 들어 사용자 ID가 karen이면 시스템 메일함은 다음과 같습니다.

text
/var/spool/mail/karen

기본 개인 메일함

개인 메일함은 사무실의 받은 서류함과 비슷합니다. 메일을 받은 뒤 정리하기 전까지 받은 서류함에 넣어 둡니다.

사용자마다 개인 메일함이 있습니다. 시스템 메일함에서 메일을 읽고 삭제 표시를 하거나 파일에 저장하지 않으면, 그 메일은 개인 메일함 $HOME/mbox($HOME은 로그인 디렉터리)에 쓰입니다. mbox 파일은 메시지가 있을 때만 존재합니다.

쓰다 만 메시지의 dead.letter 파일

다른 일을 하려고 만들던 메시지를 중단하면, 시스템은 완성하지 않은 메시지를 $HOME 디렉터리의 dead.letter 파일에 저장합니다.

dead.letter 파일이 없으면 만들어집니다. 나중에 이 파일을 편집해 메시지를 완성할 수 있습니다.

주의: dead.letter 파일을 메시지 보관용으로 쓰지 마십시오. 중단 요청으로 쓰다 만 메시지를 dead.letter에 저장할 때마다 이 파일의 내용을 덮어씁니다.

메일 폴더

폴더를 쓰면 메시지를 정리해서 저장할 수 있습니다. mail 프로그램으로 시스템 메일함, 개인 메일함, 다른 폴더의 메시지를 폴더에 넣을 수 있습니다.

폴더는 하나하나가 텍스트 파일이며, .mailrc 파일에 set folder 옵션으로 지정한 디렉터리에 놓입니다. 폴더에 메시지를 저장하기 전에 이 디렉터리를 만들어 두어야 합니다. 디렉터리가 있으면 mail 프로그램이 필요할 때 그 안에 폴더를 만듭니다. .mailrc 파일에 디렉터리를 지정하지 않으면 폴더는 현재 디렉터리에 만들어집니다. 메일 정리하기를 봅니다.

참고: 메시지 처리기(MH)와 bellmail 프로그램 등 메일을 주고받는 프로그램이 여럿 있습니다. 어떤 프로그램을 쓸지는 시스템에 무엇이 설치·구성되어 있느냐에 따라 다릅니다. 시스템 구성은 시스템 관리자에게 문의합니다.

영어 원문

Mail storage

Mail is stored in different ways, depending on the specific situation.

When mail is sent to your address, it is stored in a system directory that is specifically for mail. This system directory contains a file for every user on the local system. This directory holds your mail until you do something with it.

System mailbox

The system mailbox is similar to a post office box: the post office delivers letters addressed to the person who owns that box.

Similarly, the system mailbox is a file where messages are delivered to a particular user. If the file does not exist when mail arrives, it is created. The file is deleted when all messages have been removed.

System mailboxes reside in the /var/spool/mail directory. Each system mailbox is named by the user ID associated with it. For example, if your user ID is karen, your system mailbox is:

text
/var/spool/mail/karen

Default personal mailbox

Your personal mailbox is similar to an in-basket in an office. You put mail in the in-basket after you have received it, but before you have filed it.

Each user has a personal mailbox. When you read mail from the system mailbox, and if it is not marked for deletion or saved to a file, it is written to your personal mailbox, $HOME/mbox ($HOME is your login directory). The mbox file exists only when it contains a message.

dead.letter file for incomplete messages

If you need to interrupt a message you are creating to complete other tasks, the system saves incomplete messages in the dead.letter file in the $HOME directory.

If the dead.letter file does not exist, the file is created. Later you can edit the file to complete your message.

Attention: Do not use the dead.letter file to store messages. The content of this file is overwritten each time an interrupt is issued to save a partial message to the dead.letter file.

Mail folders

Folders enable you to save messages in an organized fashion. Using the mail program, you can put a message into a folder from the system mailbox, a personal mailbox, or another folder.

Each folder is a text file. Each folder is placed in the directory you specify in your .mailrc file with the set folder option. You must create this directory before using folders to store messages. When the directory exists, the mail program creates the folders in that directory as needed. If you do not specify a directory in your .mailrc file, folders are created in the current directory. See Organizing mail.

Note: Several programs are available to send and receive mail, including Message Handler (MH) and the bellmail program. Which program you use depends on what is installed and configured on your system. For information on your system configuration, contact your system administrator.

메일 처리와 받기

mail 프로그램으로 메일함의 메시지를 하나씩 살펴본 다음 지우거나 개인 메일 디렉터리에 정리할 수 있습니다.

명령 셸은 메일이 왔다고 알려 줍니다. MAIL 환경 변수가 설정되어 있고, 셸이 마지막으로 메일을 확인한 뒤 MAILCHECK로 지정한 시간이 지났으면, 다음 프롬프트 전에 알림이 표시됩니다. 알림 메시지는 MAILMSG 환경 변수의 값입니다. 쓰는 셸(Bourne, Korn, C 셸)에 따라 알림은 다음과 비슷합니다.

text
YOU HAVE NEW MAIL

메일함 시작

mail 명령으로 시스템 메일함의 메시지를 읽고 지웁니다.

시스템 메일함을 메시지 보관용으로 쓰지 마십시오. 메시지는 개인 메일함과 메일 폴더에 보관합니다.

시스템 메일함에 메일이 있는지 확인하기

mail 명령으로 시스템 메일함에 메일이 있는지 확인합니다. 시스템 명령줄 프롬프트에서 mail 명령을 입력합니다.

text
mail

시스템 메일함에 메일이 없으면 다음 메시지가 나옵니다.

text
No mail for YourID

메일함에 메일이 있으면 시스템 메일함의 메시지 목록이 나옵니다.

text
Mail Type ? for help.
"/usr/mail/lance": 3 messages 3 new
  >N    1 karen Tue Apr 27 16:10 12/321 "Dept Meeting"
   N    2 lois  Tue Apr 27 16:50 10/350 "System News"
   N    3 tom   Tue Apr 27 17:00 11/356 "Tools Available"

현재 메시지 앞에는 늘 보다 큼 기호(>)가 붙습니다. 한 줄짜리 항목마다 다음 필드가 표시됩니다.

필드 설명
status 메시지의 분류를 나타냅니다.
number mail 프로그램에서 그 메일을 가리키는 번호입니다.
sender 메일을 보낸 사람의 주소입니다.
date 메시지를 받은 날짜입니다.
size 메시지의 줄 수와 문자 수(머리글 포함)입니다.
subject 메시지에 제목이 있으면 그 제목입니다.

status는 다음 가운데 하나입니다.

상태 뜻
N 새 메시지
P 시스템 메일함에 보존될 메시지
U 읽지 않은 메시지. 지난번 mail 프로그램을 썼을 때 메일함 목록에는 나왔지만 내용을 보지 않은 메시지입니다.
* 파일이나 폴더에 저장(save)하거나 쓴(write) 메시지

상태 표시가 없는 메시지는 읽었지만 지우거나 저장하지 않은 메시지입니다.

개인 메일함이나 메일 폴더에 메일이 있는지 확인하기

mail 명령으로 개인 메일함이나 메일 폴더에 메일이 있는지 확인할 수 있습니다. 시스템 명령줄 프롬프트에서 다음처럼 씁니다.

  1. 개인 메일함 $HOME/mbox의 메시지 목록을 보려면 다음을 입력합니다.
text
mail -f

개인 메일함에 메일이 없으면 다음과 비슷한 메시지가 나옵니다.

text
"/u/george/mbox": 0 messages

또는

text
A file or directory in the path name does not exist
  1. dept 폴더의 메시지 목록을 보려면 다음을 입력합니다.
text
mail -f +dept

메일 폴더에 메일이 없으면 다음과 비슷한 메시지가 나옵니다.

text
A file or directory in the path name does not exist

메일함 내용 표시 옵션

메일함 프롬프트에서 메일함 하위 명령을 입력해 메일함의 내용을 다룰 수 있습니다.

다음 조건을 먼저 확인합니다.

  1. mail 프로그램이 시스템에 설치되어 있어야 합니다.
  2. mail 프로그램이 시작되어 있어야 합니다.
  3. 메일함에 메일이 있어야 합니다.

메시지 범위

h 하위 명령으로 내가 정한 메시지 목록 안의 메시지를 보면 모든 메시지를 훑어보지 않아도 됩니다. 메일함 프롬프트에서 다음처럼 씁니다.

하위 명령 설명
h 한 번에 메시지 20개쯤을 보여 줍니다. 실제 개수는 쓰는 터미널 종류와 .mailrc 파일의 set screen 옵션이 정합니다. h를 다시 입력하면 같은 범위가 나옵니다.
h 21 메시지 21부터 40까지(메일함에 그만큼 있으면) 보여 줍니다. 모든 메시지를 볼 때까지 다음 메시지 번호로 h를 계속 입력합니다.
h 1 처음 20개 묶음으로 돌아가려면 1~20 범위의 아무 번호나 입력합니다.

메일함 넘기기

z 하위 명령으로 메일함을 넘겨 봅니다.

하위 명령 설명
z 한 번에 메시지 20개쯤을 보여 줍니다. 실제 개수는 터미널 종류와 .mailrc의 set screen 옵션이 정합니다. z를 다시 입력하면 다음 20개로 넘어갑니다.
z + 더하기(+) 인수는 다음 20개로 넘어갑니다. 메시지 21부터 40까지(그만큼 있으면) 보여 줍니다. 모든 메시지를 볼 때까지 z+를 계속 입력하며, 끝에 가면 On last screenful of messages. 메시지가 나옵니다.
z - 빼기(-) 인수는 이전 20개로 돌아갑니다. 첫 묶음에 이르면 On first screenful of messages. 메시지가 나옵니다.

원하는 정보로 메시지 거르기

f 하위 명령으로 원하는 정보에 따라 메시지를 거릅니다.

하위 명령 설명
f 현재 메시지의 머리글 정보를 보여 줍니다.
f 1 4 7 메시지 1, 4, 7의 머리글 정보를 보여 줍니다.
f 1-10 메시지 1부터 10까지의 머리글 정보를 보여 줍니다.
f * 모든 메시지를 보여 줍니다.
f ron 사용자 ron이 보낸 메시지가 있으면 보여 줍니다. 입력한 주소 문자가 주소와 정확히 같을 필요는 없으므로, 대문자든 소문자든 ron은 RoN, ron@topdog, hron, rOn 주소에 모두 맞습니다.
f meet Subject: 필드에 meet가 들어 있는 메시지가 있으면 보여 줍니다. 패턴이 Subject: 필드와 정확히 같을 필요는 없고 대소문자 상관없이 들어 있기만 하면 되므로, meet는 Meeting on Thursday, Come to meeting tomorrow, MEET ME IN ST. LOUIS에 모두 맞습니다.

현재 메시지 번호

= 하위 명령은 메시지 번호를 보여 줍니다.

하위 명령 설명
= 현재 메시지 번호를 보여 줍니다.

메일함의 전체 메시지 수

folder 하위 명령으로 메일함에 메시지가 몇 개 있는지 확인합니다.

하위 명령 설명
folder 폴더나 메일함의 정보를 나열합니다. 결과는 "/u/lance/mbox": 29 messages.와 비슷합니다.

메일 읽기 옵션

메일은 여러 방법으로 읽을 수 있습니다. 방법마다 예를 들어 설명합니다. 가장 편한 방법을 골라 씁니다.

다음 조건을 먼저 확인합니다.

  1. mail 프로그램이 시스템에 설치되어 있어야 합니다.
  2. mail 프로그램이 시작되어 있어야 합니다.
  3. 시스템 메일함에 메일이 있어야 합니다.

메일함의 메시지 읽기

t나 p 하위 명령으로 메일함의 메시지를 읽습니다.

하위 명령 설명
3 메시지 번호만 입력하면 기본으로 그 메시지의 본문을 보여 줍니다.
t t 하위 명령을 쓰면 기본으로 현재 메시지의 본문을 보여 줍니다.
t 3 메시지 3의 본문을 보여 줍니다.
t 2 4 9 메시지 2, 4, 9의 본문을 보여 줍니다.
t 2-4 메시지 2부터 4까지의 본문을 보여 줍니다.
p p 하위 명령을 쓰면 기본으로 현재 메시지의 본문을 보여 줍니다(원문은 이 줄의 하위 명령을 t로 잘못 적음).
p 3 메시지 3의 본문을 보여 줍니다.
p 2 4 9 메시지 2, 4, 9의 본문을 보여 줍니다.
p 2-4 메시지 2부터 4까지의 본문을 보여 줍니다.

다음 메시지 읽기

n 하위 명령으로 메일함의 다음 메시지를 읽습니다.

하위 명령 설명
n 또는 + 다음 메시지의 본문을 보여 주고 그 메시지가 현재 메시지가 됩니다.

Enter 키를 눌러도 다음 메시지의 본문이 나옵니다.

이전 메시지 읽기

- 하위 명령으로 이전 메시지를 읽습니다.

하위 명령 설명
- 이전 메시지의 본문을 보여 줍니다.

메일 지우기

메시지를 지울 때는 현재 메시지, 특정 메시지, 메시지 범위를 지울 수 있습니다. 하위 명령을 합쳐 현재 메시지를 지우고 다음 메시지를 보여 줄 수도 있습니다.

다음 조건을 먼저 확인합니다.

  1. mail 프로그램이 시스템에 설치되어 있어야 합니다.
  2. mail 프로그램이 시작되어 있어야 합니다.
  3. 시스템 메일함에 메일이 있어야 합니다.

메시지 지우기

여러 형태의 d 하위 명령으로 메시지를 지웁니다.

하위 명령 설명
d 현재 메시지를 지웁니다.
dp 또는 dt 현재 메시지를 지우고 다음 메시지를 보여 줍니다. .mailrc 파일에 set autoprint 옵션을 넣어도 됩니다. 그러면 d가 dp나 dt처럼 동작합니다.
d 4 메시지 4를 지웁니다.
d 4-6 메시지 4부터 6까지 지웁니다.
d 2 6 8 메시지 2, 6, 8을 지웁니다.

지운 메시지 되살리기

u 하위 명령으로 지운 메시지를 되살립니다.

하위 명령 설명
u 현재 메시지를 되살립니다.
u 4 메시지 4를 되살립니다.
u 4-6 메시지 4부터 6까지 되살립니다.
u 2 6 8 메시지 2, 6, 8을 되살립니다.

mail 끝내기

다음 조건을 먼저 확인합니다.

  1. mail 프로그램이 시스템에 설치되어 있어야 합니다.
  2. mail 프로그램이 시작되어 있어야 합니다.
  3. 시스템 메일함에 메일이 있어야 합니다.

바뀐 내용을 저장하고 끝내기

q 하위 명령으로 바뀐 내용을 저장하고 mail을 끝냅니다.

시스템 메일함에서 나갈 때:

하위 명령 설명
q 시스템 메일함에서 나가 운영 체제로 돌아갑니다. 메일함을 나갈 때 삭제 표시한 메시지는 모두 메일함에서 지워지며 되살릴 수 없습니다. 읽은 메시지는 개인 메일함(mbox)에 저장됩니다. 메일을 하나도 읽지 않았으면 메시지는 처리할 때까지 시스템 메일함에 남습니다.

개인 메일함이나 메일 폴더에서 나갈 때:

하위 명령 설명
q 개인 메일함이나 메일 폴더에서 q를 쓰면 읽은 메시지와 읽지 않은 메시지 모두 처리할 때까지 개인 메일함이나 메일 폴더에 남습니다.

바뀐 내용을 저장하지 않고 끝내기

x나 ex 하위 명령으로 메일함을 바꾸지 않고 mail을 끝냅니다.

하위 명령 설명
x 또는 ex 메일함의 원래 내용을 바꾸지 않고 메일함에서 나가 운영 체제로 돌아갑니다. x 전에 한 요청은 모두 무시합니다. 다만 다른 폴더에 메시지를 저장했다면 그 저장은 이루어집니다.

메일 정리하기

폴더를 써서 메시지를 정리해 저장합니다.

폴더는 필요한 만큼 만들 수 있습니다. 사무실 서류철처럼 폴더마다 담긴 메시지의 주제에 맞는 이름을 붙입니다. 폴더는 하나하나가 텍스트 파일이며, .mailrc 파일에 set folder 옵션으로 지정한 디렉터리에 놓입니다. 폴더에 메시지를 저장하기 전에 이 디렉터리를 만들어 두어야 합니다. 디렉터리가 있으면 mail 프로그램이 필요할 때 그 안에 폴더를 만듭니다. .mailrc 파일에 set folder로 디렉터리를 지정하지 않으면 폴더는 현재 디렉터리에 만들어집니다. mail 프로그램으로 시스템 메일함, 개인 메일함, 다른 폴더의 메시지를 폴더에 넣을 수 있습니다.

s나 w 하위 명령으로 메시지 내용을 파일이나 폴더에 더할 수 있습니다. 두 하위 명령 모두 기존 파일에 정보를 덧붙이며, 파일이 없으면 새로 만듭니다. 파일에 있던 정보는 없어지지 않습니다. 시스템 메일함의 메시지를 파일이나 폴더에 저장하면 그 메시지는 시스템 메일함에서 지워지고 지정한 파일이나 폴더로 옮겨집니다. 개인 메일함이나 폴더의 메시지를 다른 파일이나 폴더에 저장하면 개인 메일함에서 지워지지 않고 지정한 파일이나 폴더로 복사됩니다. s 하위 명령을 쓰면 메시지와 머리글 정보가 폴더 끝에 덧붙으므로 그 폴더를 메일함처럼 읽을 수 있습니다. w 하위 명령을 쓰면 메시지가 머리글 정보 없이 파일 끝에 덧붙으므로 그 폴더를 파일처럼 읽을 수 있습니다.

메일을 정리하기 전에 다음 조건을 확인합니다.

  1. mail 프로그램이 시스템에 설치되어 있어야 합니다.
  2. 시스템 메일함, 개인 메일함, 내가 정의한 폴더에 메일이 있어야 합니다.
  3. mail 프로그램이 시작되어 있어야 합니다.

폴더에 메시지를 저장할 letters 메일함 디렉터리 만들기

set folder 하위 명령으로 메일함 디렉터리의 폴더에 메시지를 저장할 수 있습니다. 다음 절차를 따릅니다.

  1. .mailrc 파일에 set folder 옵션이 켜져 있는지 확인하려면 메일함 프롬프트에서 다음 하위 명령을 입력합니다.
text
set

set 하위 명령은 .mailrc 파일에서 켜진 mail 옵션 목록을 보여 줍니다. set folder 옵션이 켜져 있으면 다음과 비슷한 결과가 나옵니다.

text
folder /home/george/letters

이 예에서 letters가 메일 폴더를 저장할 디렉터리입니다.

  1. set folder 옵션이 켜져 있지 않으면 .mailrc 파일에 다음과 비슷한 줄을 더합니다.
text
set folder=/home/george/letters

이 예에서 /home/george는 George의 홈 디렉터리이고 letters는 메일 폴더를 저장할 디렉터리입니다. set folder 옵션을 켜면 메일함 프롬프트에서 더하기 기호(+) 약식 표기로 letters 디렉터리에 메시지를 저장할 수 있습니다.

  1. 홈 디렉터리에 letters 디렉터리를 만들어야 합니다. 홈 디렉터리에서 시스템 명령줄 프롬프트에 다음을 입력합니다.
text
mkdir letters

머리글과 함께 메시지 저장하기

s 하위 명령은 메시지를 머리글과 함께 저장합니다.

하위 명령 설명
s 1-4 notes 메시지 1, 2, 3, 4를 머리글 정보와 함께 현재 디렉터리의 notes 폴더에 저장합니다. 결과는 "notes" [Appended] 62/1610입니다.
s +admin 현재 메시지를 폴더 디렉터리의 기존 admin 폴더에 저장합니다. .mailrc에서 폴더 디렉터리가 /home/george/letters로 정의되어 있으면 결과는 "/home/george/letters/admin" [Appended] 14/321입니다.
s 6 +admin 메시지 6을 폴더 디렉터리의 기존 admin 폴더에 저장합니다. 결과는 위와 같습니다.

머리글 없이 메시지 저장하기

w 하위 명령으로 메시지를 폴더가 아니라 파일로 저장합니다. w로 저장한 파일을 읽거나 편집하려면 vi 같은 텍스트 편집기를 써야 합니다.

하위 명령 설명
w 6 pass 메시지 6의 본문만 현재 디렉터리의 pass 파일에 저장합니다. pass 파일이 없으면 결과는 "pass" [New file] 12/30, 있으면 "pass" [Appended] 12/30입니다.
w 1-3 safety 메시지 1, 2, 3의 본문만 현재 디렉터리의 safety 파일에 저장합니다. 메시지 본문이 한 파일에 차례로 덧붙습니다. safety 파일이 없으면 결과는 "safety" [New file] 12/30입니다.

현재 메일함이나 폴더 확인하기

folder 하위 명령으로 현재 메일함이나 폴더를 확인합니다. mail 명령은 시작할 때 현재 메일함 이름을 보여 주지만, 어느 메일함에 있는지 헷갈릴 수 있습니다.

하위 명령 설명
folder 현재 메일함이나 폴더의 이름을 찾습니다. 현재 메일함이 /home/lance/mbox면 /home/lance/mbox: 2 messages 1 deleted가 나옵니다. 곧 /home/lance/mbox가 현재 메일함이고, 메시지가 두 개 있으며, 그 가운데 하나는 이 메일함을 끝낼 때 지워진다는 뜻입니다.

다른 메일함으로 바꾸기

다른 메일함으로 바꾸는 것은 메일함이나 폴더를 끝내는 것과 같습니다. 삭제 표시한 메시지는 그 메일함을 떠날 때 지워지며 되살릴 수 없습니다. 메일함 프롬프트에서 file이나 folder 하위 명령을 씁니다.

하위 명령 설명
folder +project 메일함 하나로 mail 프로그램을 시작한 뒤 file이나 folder 하위 명령으로 다른 메일함으로 바꿉니다. mbox 파일의 메시지를 모두 지운 상태에서 project 폴더로 바꾸면 /home/dee/mbox removed +project: 2 messages 2 new가 나오고 project 폴더의 메시지 목록이 이어집니다.
영어 원문

Mail handling and receiving

The mail program enables you to examine each message in a mailbox and then delete or file a message in a personal mail directory.

The command shell notifies you that mail has arrived. The notification is displayed before the next prompt, provided that the MAIL environment variable is set and provided that the interval specified by MAILCHECK has elapsed since the shell last checked for mail. The notification message is the value of the MAILMSG environment variable. Depending on which shell you are using (bourne, korn, or C shell), the notification is similar to the following:

text
YOU HAVE NEW MAIL

Mailbox startup

Use the mail command to read and remove messages from your system mailbox.

Do not use the system mailbox to store messages. Store messages in your personal mailbox and in mail folders.

Checking your system mailbox for mail:

Use the mail command to check your system mailbox for mail.

At your system command line prompt, enter the mail command:

text
mail

If there is no mail in your system mailbox, the system responds with a message:

text
No mail for YourID

If there is mail in your mailbox, the system displays a listing of the messages in your system mailbox:

text
Mail Type ? for help.
"/usr/mail/lance": 3 messages 3 new
  >N    1 karen Tue Apr 27 16:10 12/321 "Dept Meeting"
   N    2 lois  Tue Apr 27 16:50 10/350 "System News"
   N    3 tom   Tue Apr 27 17:00 11/356 "Tools Available"

The current message is always prefixed with a greater-than symbol (>). Each one-line entry displays the following fields:

  • status — Indicates the class of the message.
  • number — Identifies the piece of mail to the mail program.
  • sender — Identifies the address of the person who sent the mail.
  • date — Specifies the date the message was received.
  • size — Defines the number of lines and characters contained in the message (this includes the header).
  • subject — Identifies the subject of the message, if it has one.

The status can be any of the following:

  • N — A new message.
  • P — A message that will be preserved in your system mailbox.
  • U — An unread message. This is a message that was listed in the mailbox the last time you used the mail program, but the contents were not examined.
  • * — A message that was saved or written to a file or folder.

A message without a status indicator is a message that has been read but has not been deleted or saved.

Checking your personal mailbox or mail folder for mail:

You can use the mail command to check your personal mailbox or mail folder for mail.

At your system command line prompt, you can use the mail command in the ways shown in the following steps:

  1. To display a listing of the messages in your personal mailbox, $HOME/mbox, enter:
text
mail -f

If there is no mail in your personal mailbox, the system responds with a message similar to the following:

text
"/u/george/mbox": 0 messages

or

text
A file or directory in the path name does not exist
  1. To display a listing of the messages in the dept folder, enter:
text
mail -f +dept

If there is no mail in your mail folder, the system responds with a message similar to the following:

text
A file or directory in the path name does not exist

Mailbox content display options

From the mailbox prompt, you can enter mailbox subcommands to manage the contents of the mailbox.

text
Prerequisites
  1. The mail program must be installed on your system.

  2. The mail program must be started.

  3. There must be mail in your mailbox.

Ranges of messages:

Use the h subcommand to view a message contained within a list of messages that you determine so that you do not have to browse through all your messages.

At your mailbox prompt, you can use the h subcommand in the ways shown in the following examples:

  • h — Approximately 20 messages are displayed at a time. The actual number displayed is determined by the type of terminal being used and the set screen option in your .mailrc file. If you enter the h subcommand again, the same range of messages is displayed.
  • h 21 — Message 21 and subsequent messages, up to and including message 40 (if you have that number of messages in your mailbox), are displayed. Continue typing the h subcommand with the subsequent message number until all messages have been displayed.
  • h 1 — To return to the first group of 20 messages, enter any number within the range of 1-20.
  • Mailbox scrolling:

Use the z subcommand to scroll through your mailbox.

At your mailbox prompt, you can use the z subcommand in the ways shown in the following examples:

  • z — Approximately 20 messages are displayed at a time. The actual number displayed is determined by the type of terminal being used and the set screen option in your .mailrc file. enter the z subcommand again to scroll to the next 20 messages.
  • z + — The plus sign (+) argument scrolls to the next 20 messages. Message 21 and subsequent messages, up to and including message 40 (if you have that number of messages in your mailbox), are displayed. Continue typing the z+ subcommand until all messages have been displayed. The system will respond with the following message: On last screenful of messages.
  • z - — The minus sign (-) argument scrolls to the previous 20 messages. When you reach the first set of messages, the system will respond with the following message: On first screenful of messages.
  • Message filtering for specific information:

At your mailbox prompt, you can use the f subcommand in the ways shown in the following examples to filter messages according to the information that you want.

  • f — Displays header information for the current message.
  • f 1 4 7 — Displays header information for the specific messages 1, 4, and 7.
  • f 1-10 — Displays header information for a range of messages 1 through 10.
  • f * — Displays all messages.
  • f ron — Messages, if any, from user ron are displayed. The characters entered for an address do not need to exactly match the address; therefore, the request for address ron in either uppercase or lowercase letters matches all of the following addresses: RoN ron@topdog hron rOn
  • fmeet — Messages, if any, where the Subject: field contains the letters meet are displayed. The characters entered for a pattern do not need to exactly match the Subject: field. They must only be contained in the Subject: field in either uppercase or lowercase letters; therefore, the request for subject meet matches all of the following subjects: Meeting on Thursday Come to meeting tomorrow MEET ME IN ST. LOUIS
  • Current message numbers:

The = subcommand displays message numbers.

At your mailbox prompt, you can use the = subcommand in the way shown in the following example:

  • = — The current message number is displayed.
  • Total number of messages in your mailbox:

Use the folder subcommand to check how many messages are in your mailbox.

At your mailbox prompt, you can use the folder subcommand in the way shown in the following example:

  • folder — Lists information about your folder or mailbox. The system will respond similarly to the following: "/u/lance/mbox": 29 messages.

Reading mail options

You can read your mail in several ways. Examples of each method are described here.

Choose the method you are most comfortable with, and use it to read your mail. Before attempting to read your mail, make sure the following conditions are true:

  1. The mail program must be installed on your system.

  2. The mail program must be started.

  3. There must be mail in your system mailbox.

Reading messages in your mailbox:

Use the t or p subcommand to read messages in your mailbox.

At your mailbox prompt, you can use the t or p subcommands in the ways shown in the following examples:

  • 3 — If you use the number of the message, by default, the text of the message is displayed.
  • t — If you use the t subcommand, by default, the text of the current message is displayed.
  • t 3 — The text of message 3 is displayed.
  • t 2 4 9 — The text for messages 2, 4, and 9 is displayed.
  • t 2-4 — The text for the range of messages 2 through 4 is displayed.
  • t — If you use the p subcommand, by default, the text of the current message is displayed.
  • p 3 — The text of message 3 is displayed.
  • p 2 4 9 — The text for messages 2, 4, and 9 is displayed.
  • p 2-4 — The text for the range of messages 2 through 4 is displayed.
  • Reading the next message in your mailbox:

Use the n subcommand to read the next message in your mailbox.

At your mailbox prompt, you can use the (n)ext or plus sign (+) subcommand in the way shown in the following example:

  • n or + — Displays the text of the next message, and this message becomes the current message.

You can also press the Enter key to display the text of the next message.

Reading the previous message in your mailbox:

Use the - subcommand to read the previous message.

At your mailbox prompt, you can use the - subcommand in the way shown in the following example:

  • - — The text of the previous message is displayed.

Deleting mail

When deleting a message, you can delete the current message, delete a specific message, or delete a range of messages.

You can also delete the current message and display the next message by combining subcommands. Ensure that the following conditions are met:

  1. The mail program must be installed on your system.

  2. There must be mail in your system mailbox.

  3. The mail program must be started.

Deleting messages:

Use various forms of the d subcommand to delete messages.

At your mailbox prompt, you can use the (d)elete subcommand in the ways shown in the following examples:

  • d — The current message is deleted.
  • dp or dt — The current message is deleted and the next message is displayed. This also can be accomplished by including the set autoprint option in the .mailrc file, which will set the d subcommand to function like the dp or dt subcommand combination.
  • d 4 — Deletes the specific message 4.
  • d 4-6 — Deletes a range of messages 4 through 6.
  • d 2 6 8 — Deletes messages 2, 6, and 8.
  • Undeleting messages:

Use the u subcommand for undeleting messages.

At your mailbox prompt, you can use the u subcommand in the ways shown in the following examples:

  • u — The current message is undeleted.
  • u 4 — Undeletes the specific message 4.
  • u 4-6 — Undeletes a range of messages 4 through 6.
  • u 2 6 8 — Undeletes messages 2, 6, and 8.

Exiting mail

Ensure that the following requirements are met before exiting the mail program.

  1. The mail program must be installed on your system.

  2. There must be mail in your system mailbox.

  3. The mail program must be started.

Exiting mail and saving changes:

Use the q subcommand to exit mail and save changes.

If you are exiting the system mailbox:

  • q — The q subcommand leaves the system mailbox and returns to the operating system. When you leave the mailbox, all messages marked to be deleted are removed from the mailbox and cannot be recovered. The mail program saves the messages you read in your personal mailbox (mbox). If you did not read any of your mail, the messages remain in the system mailbox until acted upon.

If you are exiting your personal mailbox or a mail folder:

  • q — When using the q subcommand in your personal mailbox or a mail folder, messages read and not read will remain in your personal mailbox or in a mail folder until acted upon.
  • Exiting mail without saving changes:

Use the x or ex subcommand to exit mail without making mailbox changes.

  • x or ex — The x or ex subcommand allows you to leave the mailbox and return to the operating system without changing the original contents of the mailbox. The program ignores any requests you made prior to the x request; however, if you did save a message to another folder, the save will occur.

Organizing mail

Use folders to save messages in an organized fashion.

You can create as many folders as you need. Give each folder a name that pertains to the subject matter of the messages it contains, similar to file folders in an office filing system. Each folder is a text file that is placed in the directory you specify in your .mailrc file with the set folder option. You must create this directory before using folders to store messages. When the directory exists, the mail program creates the folders in that directory as needed. If you do not specify a directory with the set folder option in your .mailrc file, the folder is created in your current directory. Using the mail program, you can put a message into a folder from the system mailbox, a personal mailbox, or another folder.

You can add the contents of a message to a file or folder using the s or w subcommands. Both of these subcommands append information to an existing file or create a new file if it does not exist. Information currently in the file is not destroyed. If you save a message from your system mailbox to a file or folder, the message is deleted from your system mailbox and transferred to the file or folder specified. If you save a message from your personal mailbox or folder to another file or folder, the message is not deleted from your personal mailbox but is copied to the specified file or folder. When using the s subcommand, you can read the folder like a mailbox because the messages and the header information are appended at the end of the folder. When using the w subcommand, you can read the folder like a file because the message is appended without header information at the end of the file.

Before organizing mail, ensure that the following requirements are met:

  1. The mail program must be installed on your system.

  2. There must be mail in your system mailbox, personal mailbox, or a folder you have defined.

  3. The mail program must be started.

Creating a letters mailbox directory to store messages in folders:

Messages can be saved in a mailbox directory folder using the set folder subcommand.

Use the following procedure to store messages in folders:

  1. To check if the set folder option has been enabled in the .mailrc file, enter the following subcommand at the mailbox prompt:
text
set

The set subcommand displays a list of the enabled mail options in your .mailrc file. If the set folder option has been enabled, the system responds with a message similar to the following:

text
folder /home/george/letters

In this example, letters is the directory in which mail folders will be stored.

  1. If the set folder option has not been enabled, add a line similar to the following in the .mailrc file:
text
set folder=/home/george/letters

In this example, /home/george is George's home directory and letters is the directory in which mail folders will be stored. The set folder option enables you to use the plus sign (+) shorthand notation at your mailbox prompt to save messages in your letters directory.

  1. You must create a letters directory in your home directory. In your home directory at the system command line prompt, type:
text
mkdir letters

Saving messages with headers:

The s subcommand saves messages with headers.

Use the s subcommand in the following ways:

  • s 1-4 notes — Saves messages 1, 2, 3 and 4 with their header information to a folder called notes in the current directory. The mail program responds with the following message: "notes" [Appended] 62/1610
  • s +admin — Saves the current message to an existing folder called admin in your folder directory. If the folder directory is defined as /home/george/letters in your .mailrc file, the system responds with: "/home/george/letters/admin" [Appended] 14/321
  • s 6 +admin — Saves message 6 to an existing folder called admin in your folder directory. If the folder directory is defined as /home/george/letters in your .mailrc file, the system responds with: "/home/george/letters/admin" [Appended] 14/321
  • Saving messages without headers:

Use the w subcommand to save a message as a file instead of as a folder.

To read or edit a file saved with the w subcommand, you must use vi or some other text editor. At your mailbox prompt, you can use the w subcommand in the following ways:

  • w 6 pass — Saves only the text of message 6 to a file called pass in the current directory. If the pass file does not already exist, the system responds with the following message: "pass" [New file] 12/30 If the pass file exists, the system responds with the following message: "pass" [Appended] 12/30
  • w 1-3 safety — Saves only the text of the specific messages 1, 2, and 3 to a file called safety in the current directory. The text of the messages in this example will be appended one after the other into one file. If the safety file does not already exist, the system responds with the following message: "safety" [New file] 12/30
  • Determining the current mailbox or folder:

Use the folder subcommand to determine the current mailbox or folder.

Although the mail command displays the name of the current mailbox when it starts, you might lose track of which mailbox you are in. At your mailbox prompt, you can use the folder subcommand shown in the following example:

  • folder — Finds the name of your current mailbox or folder. If the current mailbox is /home/lance/mbox, the following is displayed: /home/lance/mbox: 2 messages 1 deleted This message indicates that /home/lance/mbox is the current mailbox you are in, it contains two messages, and one of those messages will be deleted when you finish with this mailbox.
  • Changing to another mailbox:

Changing to another mailbox is like quitting a mailbox or folder.

Any messages that you marked to be deleted are deleted when you leave that mailbox. The deleted messages cannot be recovered. At your mailbox prompt, you can use the file or folder subcommand shown in the following example:

  • folder +project — After the mail program is started with one mailbox, use the file or folder subcommands to change to another mailbox. If you change from the mbox file to the mbox folder and you have deleted all the messages in the mbox file, the mail program displays: /home/dee/mbox removed +project: 2 messages 2 new followed by a list of the messages in the project folder.