Sie sind auf Seite 1von 8

2/15/13

mail

UNIX
Copyright B. Brown, 1988-2000. All rights reserved. March 2000.

Assignment 2a: An Introduction to mail


mail permits people on UNIX systems to send each other messages, transfer small files, act as personal reminders and communicate with people on remote systems. MailBoxes UNIX uses two mailboxes to hold mail messages
sse mibx(ursolmi/ ytm alo /s/po/al) ue mi bx(....mo) sr al o .././bx

Mail arrives in the system mailbox, and is saved in your user mail box after you have read it. The user mail box is normally located in their $HOME directory. The Format Of Mail Messages A mail message is exchanged between people. Mail messages consist of two parts
hae edr bd oy cnan ifrainaotsne,rcie adsbet otis nomto bu edr eevr n ujc ata cneto msae cul otn f esg

Mail Headers Mail headers have the following construction To: Subject: Cc: Bcc: This specifies the name of the recipients of the message (mandatory) Title describing the message (optional) List of people to receive a carbon copy (optional) List of people to receive blind carbon copy (they do not see user names in the received message. Optional)

Modes Of Operation For The mail Program The mail program operates in two main modes
cmoemd ops oe cmadmd omn oe msae aecetd esgs r rae mng yu mi,ls/dtdlt/rn/aemsae aae or al itei/eeepitsv esgs

Typing the command mail runs the mail program and checks for mail. If there is mail, command mode is entered. If there is no mail, the program returns immediately. Compose mode is entered when you invoke the mail program and specify a user as an argument, eg.
mi uenm al srae
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 1/8

2/15/13

mail

Entering mail Compose Mode This mode is entered by invoking the mail program from the UNIX command line prompt and specifying a user to which the mail should be sent. The example below invokes the mail program and names the recipient of the message as joe. The user is placed into compose mode, where the message contents is filled in (DO NOT type this example!).
mi je al o

In order for you to become familiar with the features of mail, run the mail program as show above, BUT, use your login name instead of the user joe. This means the mail will be sent to yourself. This is the best way to learn all the features of mail, without distracting other people. TYPE
mi yu_srnm al orue_ae

(where your_user_name is the login name you used to login to the UNIX host). When the mail program starts, it reads a mail script file (if one is present) located in the user home directory. This specifies options for how the mail program works. One of the options is asksub, which tells the mail program to ask for a subject heading. If this option is set, then the mail program prompts you to enter a subject line,
Sbet ujc:

Enter the string "My first message" as the subject content for this message. Subject fields are limited to a single line. The mail program is now in compose mode. Enter each of the following lines. At the end of each line press .
Ti i m frtUI mi msae hs s y is NX al esg. Ia etrn tecnet o ti msaei cmoemd. m neig h otns f hs esg n ops oe Oc Ipestertr kyIcno ei peiu lns ne rs h eun e ant dt rvos ie Hv anc dy ae ie a

Note:
T dlt aln i cmoemd,pesCRo eee ie n ops oe rs TLU T ve temsaebfr snigi,pes~ o iw h esg eoe edn t rs p T aottemsae pesteDLT kytie o br h esg, rs h EEE e wc (hshsbe mpe t CR-So teIMP kyor,ad ti a en apd o TLB n h B-C ebad n wl sv temsaei tefl da.etr il ae h esg n h ie edlte) T sn temsae pesCRo ed h esg, rs TLd

To finish entering the message, press CTRL-d. The mail message is sent, and the mail program returns you to the shell
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 2/8

2/15/13

mail

prompt. Sending a mail message contained in a file to a user If the mail message already exists in a file, this is sent to a user by typing the following command (its an example, do not type it),
mi je < msae al o esg

which sends the text file message to the user joe. 1: Create a file name "tmpfile" which contains a message to send.
ct - > tpie a mfl Hloadwloe Ti msaewsi el n ecm. hs esg a n afl nmdtpie ie ae mfl.

2: Send the file to yourself as outlined above.


mi yu_srnm < tpie al orue_ae mfl

Specifying the Subject Content when sending a message The command line option -s specifies the subject header for mail to use. The following command
mi - "etn tdya 1:0m al s Meig oa t 10a" je o < msae esg

sends the file message to the user joe and inserts the text string "Meet...am" into the subject field of the message header. Send the file "tmpfile" to yourself, using a subject header string "My message3" Entering mail command mode This mode is entered when you invoke the mail program without arguments and there is mail waiting for you. Type
mi al

The mail program displays a title message and lists all available mail headers,
SOSse VMi (eso 32 Tp ?frhl. C ytm al vrin .) ye o ep "ursolmi/rab:3msae 3nw /s/po/albin" esgs e N 3bin rab MnMy3 1:2 1/9 o a 1 50 029 M msae y esg3 N 2bin rab MnMy3 1:1 o a 1 50 928 /7 > 1bin N rab MnMy3 1:0 1/1 o a 1 50 245 M frtmsae y is esg &

This initial screen displays the subject fields of messages which have arrived. The format of the display is,
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 3/8

2/15/13

mail

Tp ye N > &

Msaenme esg_ubr

Fo_sr rmUe

Dt/ie aeTm

Sbet ujc

dntsanwmsae eoe e esg dntstecretmsae eoe h urn esg mi pop smo al rmt ybl

Note how message number 2 does not have a subject heading. This is because the mail message was sent from a file, and the -s option was not specified on the command line when the mail program was invoked. Getting help To display help whilst running the mail program, type a question (?) mark type [msglist] print messages next goto and type next message edit [msglist] edit messages from [msglist] give header lines of messages delete [msglist] delete messages undelete [msglist] restore deleted messages save [msglist] file append messages to file reply [message] reply to message, including all recipients Reply [msglist] reply to the authors of the messages preserve [msglist] preserve messages in mailbox mail user mail to specific user quit quit, preserving unread messages xit quit, preserving all messages header print page of active message headers ! shell escape cd [directory] chdir to directory or home if none given list list all commands (no explanations) top [msglist] print top 5 lines of messages z [-] display next [last] page of 10 headers [msglist] is optional and specifies messages by number, author, subject or type. The default is the current message.

Reading the current message To read the current message denoted by the > symbol, press the return key. The mailer displays the message as follows,
Msae 1 esg : Fo bin MnMy3 1:02 19 rm rab o a 1 50:0 93 Fo:bin@i1cta.z(ra Bon rm rabct.i.cn Bin rw) XMie:SOSse VMi (eso 32 -alr C ytm al vrin .) T:bin o rab Sbet M frtmsae ujc: y is esg Dt:Mn 3 My9 1:01 NT ae o, 1 a 3 50:6 Z MsaeI: <35150a106ct.i.cn> esg-D 90310.a23@i1cta.z Sau:R tts O Ti i m frtUI mi msae hs s y is NX al esg.
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 4/8

2/15/13

mail

Ia etrn tecnet o ti msaei cmoemd. m neig h otns f hs esg n ops oe Oc Ipestertr kyIcno ei peiu lns ne rs h eun e ant dt rvos ie Hv anc dy ae ie a

Read messages are not held in the system mailbox when you exit the mail program. If you want to save these messages after reading them, you must do so before exiting the mail program. To read the next message, press the return key. The mailer responds with
Msae 2 esg : Fo bin MnMy3 1:14 19 rm rab o a 1 50:8 93 Fo:bin@i1cta.z(ra Bon rm rabct.i.cn Bin rw) XMie:SOSse VMi (eso 32 -alr C ytm al vrin .) T:bin o rab Dt:Mn 3 My9 1:14 NT ae o, 1 a 3 50:7 Z MsaeI: <35151a106ct.i.cn> esg-D 90310.a24@i1cta.z Sau:R tts Hloadwloe Ti msaewsi el n ecm. hs esg a n afl nmdtpie ie ae mfl.

Using the 'header' command to view mail headers The header command in compose mode lists the headers of all mail messages. The message header contains,
Ni temsaei nw f h esg s e temsaenme (,2 3.n h esg ubr 1 , . ) teuenm o tesne h srae f h edr tedt adtm o arvl h ae n ie f ria tenme o lnstenme o btsi temsae h ubr f ie/h ubr f ye n h esg tesbetfedcnet h ujc il otns

Type the header command to list the available messages. Your display should now look like,
&hae edr N 3bin rab > 2bin rab 1bin rab & TeJn 10:3 u u 84 TeJn 10:2 u u 84 TeJn 10:1 u u 84 1/0 038 927 /8 1/1 247 M msae y esg3 M frtmsae y is esg

Reading Specific Messages Using The type Command The type command in compose mode is used to view specific messages. As an argument, it accepts, the message number or senders name. If no argument is given, it displays the current selected message denoted by the symbol >. Examples type 1 type jim type

types message 1 types the message from user jim type the current highlighted message

Type the command type without arguments.


uva.ulb.ac.be/cit_courseware/unix/unix12.htm 5/8

2/15/13

mail

Which message number was printed out?.................................................. Printing a mail message The l command prints a specified mail message. The following command prints all mail messages received from the user joe.
l je o

To print the current message, do not supply any arguments. Print the current message and attach it to this booklet for assessment. Saving a mail message The hold or preserve command saves the message in the system mail box. This means it will still be visible next time you enter mail. Leaving mail with the quit command normally saves the message in the persons mailbox. It will not appear in the list of mail messages next time the mail program is invoked. Type the command hold to preserve the current message. Follow this command by using the header command to display the message headers. Your screen should look like,
&hl od &hae edr N 3bin rab > 2bin P rab 1bin rab &

TeJn 10:3 1/0 u u 84 038 M msae y esg3 TeJn 10:2 u u 84 927 /8 TeJn 10:1 1/1 u u 84 247 M frtmsae y is esg

Note how the P symbol highlights the message as being Preserved. This message will be available next time you run the mail program, as well as un-read messages, but the messages that you have read will not be available. Saving the current mail message to a file People will generally save important messages in a file. This is done by using the save command and specifying a file to save the message in,
s meig etns

saves the current message in the file meetings. This file is now treated as a mail folder by the mail program. The command
s 1 wloe ecm

saves message number 1 in a mail folder named welcome. Save message 3 to a file name "message1" Deleting the current message
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 6/8

2/15/13

mail

The delete command deletes messages.


eape xmls dlt je eee o dlt 1 eee dlt temsaefo ue je eee h esg rm sr o dlt msaenme 1 eee esg ubr

Replying to a mail message The reply command allows you to send a reply to the sender of the message.
eape xmls rpy 2 el rpy el rpyt msaenme 2 el o esg ubr rpyt tecretmsae el o h urn esg

If the original message contains a subject field, the mailer will automatically fill this in for you, taking the contents of the original messages subject field. Forwarding a mail message A message is forwarded (sent on to) another user by using the forward command.
eape xmls f 1 bin rab f 2 bin je rab o fradmsaenme 1t ue bin owr esg ubr o sr rab fradmsaenme 2t bin adje owr esg ubr o rab n o

Working in Compose Mode In compose mode, the mail program accepts special key sequences. These commands begin with the tidle (~) symbol. You will note that if you make a mistake on a previous line, you cannot go back and change it (at least not yet). Using the command sequence ~v invokes the UNIX editor vi, and permits you to edit the message you have entered. After exiting vi, you are back into mail compose mode, where you continue entering lines or send the message by pressing ctrl-d. To display a list of available escape sequences, enter the following command whilst in compose mode.
~ ?

To list previous entered lines whilst in compose mode, press ~p You can abort the sending of a message by pressing the interrupt key (either BACKSPACE or CTRL-BACKSPACE) twice. If you abort a message in this manner, the message is saved in the file dead.letter in your $HOME directory. Using different mail folders When the mail program starts, it uses the default mail folder, which is the system mailbox. Remember the save mail message command, which saved the mail message to a file. It was stated that the mail program treats this file as a mail folder. By specifying the mail folder on the command line as an argument, mail will use a different mail folder.
uva.ulb.ac.be/cit_courseware/unix/unix12.htm 7/8

2/15/13

mail

mi - meig al f etns

Executing shell commands UNIX commands are executed from within the mailer by preceding them with an exclamation symbol
eape xmls !s-a l l !h s d adrcoylsig o ietr itn rnasel u hl

Sending Mail To People At Other Host Machines Or Sites You send mail to other people at remote sites by specifying their specific mail address.
eape xmls binbincta.z ra@ra.i.cn o2srbincta.z sue@ra.i.cn yu_srnm@s.i.cn orue_aecccta.z

You can practise this by sending mail to yourself. As a student at CIT, you have an account on one of the student Netware servers. This is connected to the mail system of the CIT UNIX host, cit1. Your mail address is thus,
yu_srnm@evrnm.i.cn orue_aesre_aecta.z

For instance, if your username was huntsam, and the Netware server name was CC2, then your mail address is
hnsmc2cta.z uta@c.i.cn

Send yourself a mail message to your account. Note: This only works if you have been enabled with INTERNET access!

uva.ulb.ac.be/cit_courseware/unix/unix12.htm

8/8

Das könnte Ihnen auch gefallen