new copyright; att/bsd/shared
[unix-history] / usr / src / usr.bin / mail / USD.doc / mail4.nr
CommitLineData
ff262511
KB
1.\" Copyright (c) 1980 The Regents of the University of California.
2.\" All rights reserved.
e1802a75 3.\"
ff262511
KB
4.\" %sccs.include.redist.roff%
5.\"
6.\" @(#)mail4.nr 6.4 (Berkeley) %G%
e1802a75 7.\"
6d7e256b
KD
8.bp
9.sh 1 "More about sending mail"
10.sh 2 "Tilde escapes"
11.pp
12While typing in a message to be sent to others, it is often
13useful to be able to invoke the text editor on the partial message,
14print the message, execute a shell command, or do some other
15auxiliary function.
16.i Mail
17provides these capabilities through
18.i "tilde escapes" ,
19which consist of a tilde (~) at the beginning of a line, followed by
20a single character which indicates the function to be performed. For
21example, to print the text of the message so far, use:
22.(l
23~p
24.)l
25which will print a line of dashes, the recipients of your message, and
26the text of the message so far.
27Since
28.i Mail
29requires two consecutive \s-2RUBOUT\s0's to abort a letter, you
30can use a single \s-2RUBOUT\s0 to abort the output of ~p or any other
31~ escape without killing your letter.
32.pp
33If you are dissatisfied with the message as
34it stands, you can invoke the text editor on it using the escape
35.(l
36~e
37.)l
38which causes the message to be copied into a temporary file and an
39instance of the editor to be spawned. After modifying the message to
40your satisfaction, write it out and quit the editor.
41.i Mail
42will respond
43by typing
44.(l
45(continue)
46.)l
47after which you may continue typing text which will be appended to your
48message, or type <control-d> to end the message.
49A standard text editor is provided by
50.i Mail .
51You can override this default by setting the valued option
52.q EDITOR
53to something else. For example, you might prefer:
54.(l
55set EDITOR=/usr/ucb/ex
56.)l
57.pp
58Many systems offer a screen editor as an alternative to the standard
59text editor, such as the
60.i vi
61editor from UC Berkeley.
62To use the screen, or
63.i visual
64editor, on your current message, you can use the escape,
65.(l
66~v
67.)l
68~v works like ~e, except that the screen editor is invoked instead.
69A default screen editor is defined by
70.i Mail .
71If it does not suit you, you can set the valued option
72.q VISUAL
73to the path name of a different editor.
74.pp
75It is often useful to be able to include the contents of some
76file in your message; the escape
77.(l
78~r filename
79.)l
80is provided for this purpose, and causes the named file to be appended
81to your current message.
82.i Mail
83complains if the file doesn't exist
84or can't be read. If the read is successful, the number of lines and
85characters appended to your message is printed, after which you may continue
86appending text. The filename may contain shell metacharacters like * and ?
87which are expanded according to the conventions of your shell.
88.pp
89As a special case of ~r, the escape
90.(l
91~d
92.)l
93reads in the file
94.q dead.letter
95in your home directory. This is often useful since
96.i Mail
97copies the text
98of your message there when you abort a message with \s-2RUBOUT\s0.
99.pp
100To save the current text of your message on a file you may use the
101.(l
102~w filename
103.)l
104escape.
105.i Mail
106will print out the number of lines and characters written
107to the file, after which you may continue appending text to your message.
108Shell metacharacters may be used in the filename, as in ~r and are expanded
109with the conventions of your shell.
110.pp
111If you are sending mail from within
112.i Mail's
113command mode
114you can read a message sent to you into the message
115you are constructing with the escape:
116.(l
117~m 4
118.)l
119which will read message 4 into the current message, shifted right by
120one tab stop. You can name any non-deleted message, or list of messages.
121Messages can also be forwarded without shifting by a tab stop with ~f.
122This is the usual way to forward a message.
123.pp
124If, in the process of composing a message, you decide to add additional
125people to the list of message recipients, you can do so with the escape
126.(l
127~t name1 name2 ...
128.)l
129You may name as few or many additional recipients as you wish. Note
130that the users originally on the recipient list will still receive
131the message; you cannot remove someone from the recipient
132list with ~t.
133.pp
134If you wish, you can associate a subject with your message by using the
135escape
136.(l
137~s Arbitrary string of text
138.)l
139which replaces any previous subject with
140.q "Arbitrary string of text."
141The subject, if given, is sent near the
142top of the message prefixed with
143.q "Subject:"
144You can see what the message will look like by using ~p.
145.pp
146For political reasons, one occasionally prefers to list certain
147people as recipients of carbon copies of a message rather than
148direct recipients. The escape
149.(l
150~c name1 name2 ...
151.)l
152adds the named people to the
153.q "Cc:"
154list, similar to ~t.
155Again, you can execute ~p to see what the message will look like.
156.pp
8c80966d
CL
157The escape
158.(l
159~b name1 name2 ...
160.)l
161adds the named people to the
162.q "Cc:"
163list, but does not make the names visible in the
164.q "Cc:"
165line ("blind" carbon copy).
166.pp
6d7e256b
KD
167The recipients of the message together constitute the
168.q "To:"
169field, the subject the
170.q "Subject:"
171field, and the carbon copies the
172.q "Cc:"
8c80966d
CL
173field. If you wish to edit these in ways impossible with the ~t, ~s, ~c
174and ~b escapes, you can use the escape
6d7e256b
KD
175.(l
176~h
177.)l
178which prints
179.q "To:"
180followed by the current list of recipients and leaves the cursor
181(or printhead) at the end of the line. If you type in ordinary
182characters, they are appended to the end of the current list of
183recipients. You can also use your erase character to erase back into
184the list of recipients, or your kill character to erase them altogether.
185Thus, for example, if your erase and kill characters are the standard
186(on printing terminals) # and @ symbols,
187.(l
188~h
189To: root kurt####bill
190.)l
191would change the initial recipients
192.q "root kurt"
193to
194.q "root bill."
195When you type a newline,
196.i Mail
197advances to the
198.q "Subject:"
199field, where the same rules apply. Another newline brings you to
200the
201.q "Cc:"
202field, which may be edited in the same fashion. Another newline
0b9ed661
CL
203brings you to the
204.q "Bcc:"
205("blind" carbon copy) field, which follows the same rules as the "Cc:"
206field. Another newline
6d7e256b
KD
207leaves you appending text to the end of your message. You can use
208~p to print the current text of the header fields and the body
209of the message.
210.pp
211To effect a temporary escape to the shell, the escape
212.(l
213~!command
214.)l
215is used, which executes
216.i command
217and returns you to mailing mode without altering the text of
218your message. If you wish, instead, to filter the body of your
219message through a shell command, then you can use
220.(l
221~|command
222.)l
223which pipes your message through the command and uses the output
224as the new text of your message. If the command produces no output,
225.i Mail
226assumes that something is amiss and retains the old version
227of your message. A frequently-used filter is the command
228.i fmt ,
229designed to format outgoing mail.
230.pp
231To effect a temporary escape to
232.i Mail
233command mode instead, you can use the
234.(l
235~:\fIMail command\fP
236.)l
237escape. This is especially useful for retyping the message you are
238replying to, using, for example:
239.(l
240~:t
241.)l
242It is also useful for setting options and modifying aliases.
243.pp
8c80966d
CL
244If you wish abort the current message, you can use the escape
245.(l
246~q
247.)l
248This will terminate the current message and return you to the
249shell (or \fIMail\fP if you were using the \fBmail\fP command).
250If the \fBsave\fP option is set, the message will be copied
251to the file
252.q dead.letter
253in your home directory.
254.pp
6d7e256b
KD
255If you wish (for some reason) to send a message that contains
256a line beginning with a tilde, you must double it. Thus, for example,
257.(l
258~~This line begins with a tilde.
259.)l
260sends the line
261.(l
262~This line begins with a tilde.
263.)l
264.pp
265Finally, the escape
266.(l
267~?
268.)l
269prints out a brief summary of the available tilde escapes.
270.pp
271On some terminals (particularly ones with no lower case)
272tilde's are difficult to type.
273.i Mail
274allows you to change the escape character with the
275.q escape
276option. For example, I set
277.(l
278set escape=]
279.)l
280and use a right bracket instead of a tilde. If I ever need to
281send a line beginning with right bracket, I double it, just as for ~.
282Changing the escape character removes the special meaning of ~.
283.sh 2 "Network access"
284.pp
285This section describes how to send mail to people on other machines.
286Recall that sending to a plain login name sends mail to that person
287on your machine. If your machine is directly (or sometimes, even,
288indirectly) connected to the Arpanet, you can send messages to people
289on the Arpanet using a name of the form
290.(l
291name@host.domain
292.)l
293where
294.i name
295is the login name of the person you're trying to reach,
296.i host
297is the name of the machine on the Arpanet,
298and
299.i domain
300is the higher-level scope within which the hostname is known, e.g. EDU (for educational
301institutions), COM (for commercial entities), GOV (for governmental agencies),
302ARPA for many other things, BITNET or CSNET for those networks.
303.pp
304If your recipient logs in on a machine connected to yours by
305UUCP (the Bell Laboratories supplied network that communicates
306over telephone lines), sending mail can be a bit more complicated.
307You must know the list of machines through which your message must
308travel to arrive at his site. So, if his machine is directly connected
309to yours, you can send mail to him using the syntax:
310.(l
311host!name
312.)l
313where, again,
314.i host
315is the name of the machine and
316.i name
317is the login name.
318If your message must go through an intermediary machine first, you
319must use the syntax:
320.(l
321intermediary!host!name
322.)l
323and so on. It is actually a feature of UUCP that the map of all
324the systems in the network is not known anywhere (except where people
325decide to write it down for convenience). Talk to your system administrator
326about good ways to get places; the
327.i uuname
328command will tell you systems whose names are recognized, but not which
329ones are frequently called or well-connected.
330.pp
331When you use the
332.b reply
333command to respond to a letter, there is a problem of figuring out the
334names of the users in the
335.q "To:"
336and
337.q "Cc:"
338lists
339.i "relative to the current machine" .
340If the original letter was sent to you by someone on the local machine,
341then this problem does not exist, but if the message came from a remote
342machine, the problem must be dealt with.
343.i Mail
344uses a heuristic to build the correct name for each user relative
345to the local machine. So, when you
346.b reply
347to remote mail, the names in the
348.q "To:"
349and
350.q "Cc:"
351lists may change somewhat.
352.sh 2 "Special recipients"
353.pp
354As described previously, you can send mail to either user names or
355.b alias
356names. It is also possible to send messages directly to files or to
357programs, using special conventions. If a recipient name has a
358`/' in it or begins with a `+', it is assumed to be the
359path name of a file into which
360to send the message. If the file already exists, the message is
361appended to the end of the file. If you want to name a file in
362your current directory (ie, one for which a `/' would not usually
363be needed) you can precede the name with `./'
364So, to send mail to the file
365.q memo
366in the current directory, you can give the command:
367.(l
368% Mail ./memo
369.)l
370If the name begins with a `+,' it is expanded into the full path name
371of the folder name in your folder directory.
372This ability to send mail to files can be used for a variety of
373purposes, such as maintaining a journal and keeping a record of
374mail sent to a certain group of users. The second example can be
375done automatically by including the full pathname of the record
376file in the
377.b alias
378command for the group. Using our previous
379.b alias
380example, you might give the command:
381.(l
382alias project sam sally steve susan /usr/project/mail_record
383.)l
384Then, all mail sent to "project" would be saved on the file
385.q /usr/project/mail_record
386as well as being sent to the members of the project. This file
387can be examined using
388.i "Mail \-f" .
389.pp
390It is sometimes useful to send mail directly to a program, for
391example one might write a project billboard program and want to access
392it using
393.i Mail .
394To send messages to the billboard program, one can send mail
395to the special name `|billboard' for example.
396.i Mail
397treats recipient names that begin with a `|' as a program to send
398the mail to. An
399.b alias
400can be set up to reference a `|' prefaced name if desired.
401.i Caveats :
402the shell treats `|' specially, so it must be quoted on the command
403line. Also, the `| program' must be presented as a single argument to
404mail. The safest course is to surround the entire name with double
405quotes. This also applies to usage in the
406.b alias
407command. For example, if we wanted to alias `rmsgs' to `rmsgs \-s'
408we would need to say:
409.(l
410alias rmsgs "| rmsgs -s"
411.)l