1.\" $NetBSD: mail.1,v 1.39 2006/10/31 22:10:41 wiz Exp $ 2.\" 3.\" Copyright (c) 1980, 1990, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)mail.1 8.8 (Berkeley) 4/28/95 31.\" 32.Dd October 31, 2006 33.Dt MAIL 1 34.Os 35.Sh NAME 36.Nm mail , 37.Nm mailx , 38.Nm Mail 39.Nd send and receive mail 40.Sh SYNOPSIS 41.Nm 42.Op Fl EIinv 43.Op Fl a Ar file 44.Op Fl b Ar bcc-addr 45.Op Fl c Ar cc-addr 46.Op Fl s Ar subject 47.Ar to-addr ... 48.Op Ar sendmail-flags 49.Nm 50.Op Fl EIiNnv 51.Op Fl H Ns Op Ns : Ns Op dnoru 52.Fl f 53.Op Ar name 54.Nm 55.Op Fl EIiNnv 56.Op Fl H Ns Op : Ns Op dnoru 57.Op Fl u Ar user 58.Sh DESCRIPTION 59.Nm 60is an intelligent mail processing system, which has 61a command syntax reminiscent of 62.Xr \&ed 1 63with lines replaced by messages. 64.Pp 65.Bl -tag -width flag 66.It Fl a 67Attach 68.Ar file 69to the message. 70.Ar file 71may be a white-space delimited list of filenames, so care must be 72taken to properly quote filenames that contain white-space. 73.It Fl b 74Send blind carbon copies to 75.Ar list . 76List should be a comma-separated list of names. 77.It Fl c 78Send carbon copies to 79.Ar list 80of users. 81.It Fl E 82Don't send messages with an empty body. 83This is useful for piping errors from cron scripts. 84.It Fl f 85Read in the contents of your 86.Ar mbox 87(or the specified file) 88for processing; when you 89.Ic quit , 90.Nm 91writes undeleted messages back to this file. 92.It Fl H 93Print the header summaries and exit. 94The optional flag modifier string must begin with a 95.Sq \&: 96and be followed by one or more of the 97characters 98.Sq d , 99.Sq n , 100.Sq o , 101.Sq r , 102or 103.Sq u 104to restrict the display to 105.Sq deleted , 106.Sq new , 107.Sq old , 108.Sq read , 109or 110.Sq unread 111messages, respectively. 112E.g., 113.Qo 114.Nm 115.Fl H Ns :n 116.Qc 117will display just new message headers. 118.It Fl I 119Forces mail to run in interactive mode even when 120input isn't a terminal. 121In particular, the 122.Sq Ic \&~ 123special 124character when sending mail is only active in interactive mode. 125.It Fl i 126Ignore tty interrupt signals. 127This is particularly useful when using 128.Nm 129on noisy phone lines. 130.It Fl N 131Inhibits the initial display of message headers 132when reading mail or editing a mail folder. 133.It Fl n 134Inhibits reading 135.Pa /etc/mail.rc 136upon startup. 137.It Fl s 138Specify subject on command line 139(only the first argument after the 140.Fl s 141flag is used as a subject; be careful to quote subjects 142containing spaces.) 143.It Fl u 144Is equivalent to: 145.Pp 146.Dl mail -f /var/mail/user 147.It Fl v 148Verbose mode. 149The details of delivery are displayed on the user's terminal. 150.El 151.Ss Sending mail 152To send a message to one or more people, 153.Nm 154can be invoked with arguments which are the names of people to 155whom the mail will be sent. 156You are then expected to type in your message, followed by an 157.Sq Li control\-D 158at the beginning of a line. 159.Pp 160Any flags following the list of recipients, with arguments, will 161be passed directly to 162.Xr sendmail 1 . 163For example to change your 164.Dv From 165address to 166.Dv somebody@somewhere.net 167you can specify: 168.Pp 169.Dl mail recipient -f somebody@somewhere.net 170.Pp 171To prevent multiple copies of a message being sent to the same 172address, duplicate addresses (after alias expansion) are removed from 173the 174.Ar bcc-addr , 175.Ar cc-addr , 176and 177.Ar to-addr 178lists. 179In addition, addresses on the 180.Ar cc-addr 181and 182.Ar to-addr 183lists are removed if they occur on the 184.Ar bcc-addr 185list and addresses on the 186.Ar cc-addr 187list are removed if they occur on the 188.Ar to-addr 189list. 190If the 191.Ar to-addr 192list is empty after these deletions, most systems will insert the line 193.Dq To: undisclosed recipients:; . 194.Pp 195The section below 196.Sx Replying to or originating mail , 197describes some features of 198.Nm 199available to help you compose your letter. 200.Ss Reading mail 201In normal usage 202.Nm 203is given no arguments and checks your mail out of the post office, 204then prints out a one line header of each message found. 205The current message is initially the first message (numbered 1) 206and can be printed using the 207.Ic print 208command (which can be abbreviated 209.Ql Ic p ) . 210You can move among the messages much as you move between lines in 211.Xr \&ed 1 , 212with the commands 213.Ql Ic \&+ 214and 215.Ql Ic \&\- 216moving backwards and forwards, and simple numbers. 217.Ss Disposing of mail 218After examining a message you can 219.Ic delete 220.Pq Ql Ic d 221the message or 222.Ic reply 223.Pq Ql Ic r 224to it. 225Deletion causes the 226.Nm 227program to forget about the message. 228This is not irreversible; the message can be 229.Ic undeleted 230.Pq Ql Ic u 231by giving its number, or the 232.Nm 233session can be aborted by giving the 234.Ic exit 235.Pq Ql Ic x 236command. 237Deleted messages will, however, usually disappear never to be seen again. 238.Ss Specifying messages 239Commands such as 240.Ic print 241and 242.Ic delete 243can be given a list of message numbers as arguments to apply 244to a number of messages at once. 245Thus 246.Dq Li delete 1 2 247deletes messages 1 and 2, while 248.Dq Li delete 1\-5 249deletes messages 1 through 5. 250The special name 251.Ql Li \&* 252addresses all messages, and 253.Ql Li \&$ 254addresses the last message; thus the command 255.Ic top 256which prints the first few lines of a message could be used in 257.Dq Li top \&* 258to print the first few lines of all messages. 259.Ss Replying to or originating mail 260You can use the 261.Ic reply 262command to set up a response to a message, sending it back to the 263person who it was from. 264Text you then type in, up to an end-of-file, 265defines the contents of the message. 266While you are composing a message, 267.Nm 268treats lines beginning with the character 269.Ql Ic \&~ 270specially. 271For instance, typing 272.Ql Ic \&~m 273(alone on a line) will place a copy 274of the current message into the response right shifting it by a tabstop 275(see 276.Em indentprefix 277variable, below). 278Other escapes will set up subject fields, add and delete recipients 279to the message, and allow you to escape to an editor to revise the 280message or to a shell to run some commands. 281(These options are given in the summary below.) 282.Ss Ending a mail processing session 283You can end a 284.Nm 285session with the 286.Ic quit 287.Pq Ql Ic q 288command. 289Messages which have been examined go to your 290.Ar mbox 291file unless they have been deleted in which case they are discarded. 292Unexamined messages go back to the post office. 293(See the 294.Fl f 295option above). 296.Ss Personal and systemwide distribution lists 297It is also possible to create a personal distribution lists so that, 298for instance, you can send mail to 299.Dq Li cohorts 300and have it go 301to a group of people. 302Such lists can be defined by placing a line like 303.Pp 304.Dl alias cohorts bill ozalp jkf mark kridle@ucbcory 305.Pp 306in the file 307.Pa \&.mailrc 308in your home directory. 309The current list of such aliases can be displayed with the 310.Ic alias 311command in 312.Nm . 313System wide distribution lists can be created by editing 314.Pa /etc/mail/aliases , 315see 316.Xr aliases 5 317and 318.Xr sendmail 1 ; 319these are kept in a different syntax. 320In mail you send, personal aliases will be expanded in mail sent 321to others so that they will be able to 322.Ic reply 323to the recipients. 324System wide 325.Ic aliases 326are not expanded when the mail is sent, 327but any reply returned to the machine will have the system wide 328alias expanded as all mail goes through 329.Xr sendmail 1 . 330.Ss Network mail (ARPA, UUCP, Berknet) 331See 332.Xr mailaddr 7 333for a description of network addresses. 334.Pp 335.Nm 336has a number of options which can be set in the 337.Pa .mailrc 338file to alter its behavior; thus 339.Dq Li set askcc 340enables the 341.Ar askcc 342feature. 343(These options are summarized below.) 344.Sh SUMMARY 345(Adapted from the 346.Dq Mail Reference Manual ) 347.Pp 348Each command is typed on a line by itself, and may take arguments 349following the command word. 350The command need not be typed in its 351entirety \- the first command which matches the typed prefix is used. 352For commands which take message lists as arguments, if no message 353list is given, then the next message forward which satisfies the 354command's requirements is used. 355If there are no messages forward of the current message, the search 356proceeds backwards, and if there are no good messages at all, 357.Nm 358types 359.Dq Li \&No applicable messages 360and aborts the command. 361.Bl -tag -width delete 362.It Ic \&\- 363Print out the preceding message. 364If given a numeric 365argument 366.Ar n , 367goes to the 368.Ar n Ap th 369previous message and prints it. 370.It Ic \&? 371Prints a brief summary of commands. 372.It Ic \&! 373Executes the shell 374(see 375.Xr sh 1 376and 377.Xr csh 1 ) 378command which follows. 379.It Ic \&| 380Pipe the current message body through the shell 381(see 382.Xr sh 1 383and 384.Xr csh 1 ) 385command which follows. 386.It Ic More 387.Pq Ic M 388Like 389.Ic more 390but also prints out ignored header fields. 391.It Ic Page 392.Pq Ic \&Pa 393A synonym for 394.Ic More . 395.It Ic Print 396.Pq Ic P 397Like 398.Ic print 399but also prints out ignored header fields. 400See also 401.Ic print , 402.Ic more , 403.Ic page , 404.Ic view , 405.Ic ignore , 406and 407.Ic retain . 408.It Ic Reply 409.Pq Ic R 410Reply to originator. 411Does not reply to other recipients of the original message. 412.It Ic Save 413.Pq Ic S 414Same as 415.Ic save 416except that all header fields are saved ignoring the 417.Ic saveignore 418or 419.Ic saveretain 420lists. 421.It Ic Type 422.Pq Ic T 423Identical to the 424.Ic Print 425command. 426.It Ic View 427.Pq Ic V 428Like 429.Ic Print 430but has the opposite MIME decoding behavior. 431(See the 432.Ar mime-decode-message 433variable.) 434.It Ic alias 435.Pq Ic a 436With no arguments, prints out all currently-defined aliases. 437With one argument, prints out that alias. 438With more than one argument, creates 439a new alias or changes an old one. 440.It Ic alternates 441.Pq Ic alt 442The 443.Ic alternates 444command is useful if you have accounts on several machines. 445It can be used to inform 446.Nm 447that the listed addresses are really you. 448When you 449.Ic reply 450to messages, 451.Nm 452will not send a copy of the message to any of the addresses 453listed on the 454.Ic alternates 455list. 456If the 457.Ic alternates 458command is given with no argument, the current set of alternative 459names is displayed. 460.It Ic chdir 461.Pq Ic c 462Changes the user's working directory to that specified, if given. 463If no directory is given, then changes to the user's login directory. 464.It Ic copy 465.Pq Ic co 466The 467.Ic copy 468command does the same thing that 469.Ic save 470does, except that it does not mark the messages it 471is used on for deletion when you quit. 472.It Ic delete 473.Pq Ic d 474Takes a list of messages as argument and marks them all as deleted. 475Deleted messages will not be saved in 476.Ar mbox , 477nor will they be available for most other commands. 478.It Ic dp 479(also 480.Ic dt ) 481Deletes the current message and prints the next message. 482If there is no next message, 483.Nm 484says 485.Dq Li "at EOF" . 486.It Ic edit 487.Pq Ic e 488Takes a list of messages and points the text editor at each one in 489turn. 490On return from the editor, the message is read back in. 491.It Ic exit 492.Po Ic ex 493or 494.Ic x 495.Pc 496Effects an immediate return to the Shell without 497modifying the user's system mailbox, his 498.Ar mbox 499file, or his edit file in 500.Fl f . 501.It Ic file 502.Pq Ic fi 503The same as 504.Ic folder . 505.It Ic folders 506List the names of the folders in your folder directory. 507.It Ic folder 508.Pq Ic fo 509The 510.Ic folder 511command switches to a new mail file or folder. 512With no arguments, it tells you which file you are currently reading. 513If you give it an argument, it will write out changes (such 514as deletions) you have made in the current file and read in 515the new file. 516Some special conventions are recognized for the name. 517.Sq # 518means the previous file, 519.Sq % 520means your system mailbox, 521.Dq %user 522means user's system mailbox, 523.Sq \*[Am] 524means your 525.Ar mbox 526file, and 527.Dq +folder 528means a file in your folder directory. 529.It Ic from 530.Pq Ic f 531Takes a list of messages and prints their message headers. 532.It Ic headers 533.Pq Ic h 534Lists the current range of headers, which is an 18\-message group. 535If a 536.Ql \&+ 537argument is given, then the next 18\-message group is printed, and 538if a 539.Ql \&\- 540argument is given, the previous 18\-message group is printed. 541.It Ic help 542A synonym for 543.Ic \&? 544.It Ic hold 545.Po Ic ho , 546also 547.Ic preserve 548.Pc 549Takes a message list and marks each message therein to be saved in 550the user's system mailbox instead of in 551.Ar mbox . 552Does not override the 553.Ic delete 554command. 555.It Ic ignore 556Add the list of header fields named to the 557.Ar ignored list . 558Header fields in the ignore list are not printed 559on your terminal when you print a message. 560This command is very handy for suppression of certain machine-generated 561header fields. 562The 563.Ic Type 564and 565.Ic Print 566commands can be used to print a message in its entirety, including 567ignored fields. 568.It Ic inc 569Incorporate any new messages that have arrived while mail 570is being read. 571The new messages are added to the end of the message list, 572and the current message is reset to be the first new mail message. 573This does not renumber the existing message list, nor does 574it cause any changes made so far to be saved. 575If 576.Ic ignore 577is executed with no arguments, it lists the current set of 578ignored fields. 579.It Ic mail 580.Pq Ic m 581Takes as argument login names and distribution group names and sends 582mail to those people. 583.It Ic mbox 584Indicate that a list of messages be sent to 585.Ic mbox 586in your home directory when you quit. 587This is the default action for messages if you do 588.Em not 589have the 590.Ic hold 591option set. 592.It Ic mkread 593.Pq Ic mk 594Takes a message list and marks each message as 595having been read. 596.It Ic more 597.Pq Ic \&mo 598Takes a message list and invokes the pager on that list. 599.It Ic next 600.Pf ( Ic n , 601like 602.Ic \&+ 603or 604.Tn CR ) 605Goes to the next message in sequence and types it. 606With an argument list, types the next matching message. 607.It Ic page 608.Pq Ic pa 609A synonym for 610.Ic more . 611.It Ic preserve 612.Pq Ic pre 613A synonym for 614.Ic hold . 615.It Ic print 616.Pq Ic p 617Takes a message list and types out each message on the user's terminal. 618.It Ic quit 619.Pq Ic q 620Terminates the session, saving all undeleted, unsaved messages in 621the user's 622.Ar mbox 623file in his login directory, preserving all messages marked with 624.Ic hold 625or 626.Ic preserve 627or never referenced in his system mailbox, and removing all other 628messages from his system mailbox. 629If new mail has arrived during the session, the message 630.Dq Li "You have new mail" 631is given. 632If given while editing a mailbox file with the 633.Fl f 634flag, then the edit file is rewritten. 635A return to the Shell is effected, unless the rewrite of edit file 636fails, in which case the user can escape with the 637.Ic exit 638command. 639.It Ic reply 640.Pq Ic r 641Takes a message list and sends mail to the sender and all 642recipients of the specified message. 643The default message must not be deleted. 644.It Ic respond 645A synonym for 646.Ic reply . 647.It Ic retain 648Add the list of header fields named to the 649.Ar retained list . 650Only the header fields in the retained list 651are shown on your terminal when you print a message. 652All other header fields are suppressed. 653The 654.Ic type 655and 656.Ic print 657commands can be used to print a message in its entirety. 658If 659.Ic retain 660is executed with no arguments, it lists the current set of 661retained fields. 662.It Ic save 663.Pq Ic s 664Takes a message list and a filename and appends each message in 665turn to the end of the file. 666The filename in quotes, followed by the line 667count and character count is echoed on the user's terminal. 668.It Ic set 669.Pq Ic se 670With no arguments, prints all variable values. 671Otherwise, sets option. 672Arguments are of the form 673.Ar option=value 674(no space before or after =) or 675.Ar option . 676Quotation marks may be placed around any part of the assignment 677statement to quote blanks or tabs, i.e. 678.Dq Li "set indentprefix=\*q-\*[Gt]\*q" 679.It Ic saveignore 680.Ic Saveignore 681is to 682.Ic save 683what 684.Ic ignore 685is to 686.Ic print 687and 688.Ic type . 689Header fields thus marked are filtered out when 690saving a message by 691.Ic save 692or when automatically saving to 693.Ar mbox . 694.\" .pl +1 695.It Ic saveretain 696.Ic Saveretain 697is to 698.Ic save 699what 700.Ic retain 701is to 702.Ic print 703and 704.Ic type . 705Header fields thus marked are the only ones saved 706with a message when saving by 707.Ic save 708or when automatically saving to 709.Ar mbox . 710.Ic Saveretain 711overrides 712.Ic saveignore . 713.It Ic shell 714.Pq Ic sh 715Invokes an interactive version of the shell. 716.It Ic show 717.Pq Ic sho 718Takes a list of variables and prints out their values in the form 719.Ar option=value . 720If the list is empty, all variable values are shown. 721.It Ic size 722Takes a message list and prints out the size in characters of each 723message. 724.It Ic smopts 725Takes an 726.Sq address-spec 727followed by the sendmail flags that should be used when sending mail 728to an address that matches that 729.Sq address-spec . 730If no sendmail flags are specified, then list the sendmail flags in 731effect for the 732.Sq address-spec . 733If the 734.Sq address-spec 735is also omitted, then list all 736.Ic smopts 737settings. 738The 739.Sq address-spec 740may be an alias, address, domain (beginning with a 741.Sq @ ) , 742or subdomain 743(begining with a 744.Sq \&. ) . 745If mail is sent to multiple users, the sendmail flags are 746used only if the flags are the same for each recipients. 747If 748.Ar smopts-verify 749is set, then you will be asked to verify the sendmail flags (if there 750are any) before the mail is sent. 751Address matching is case insensitive and done from most specific to 752least. 753.Pp 754For example if 755you have: 756.Bd -literal -offset indent 757smopts mylist -F "List Maintainer" 758smopts @NetBSD.org -f anon@somewhere.net -F "Anon Ymous" 759smopts friend@NetBSD.org "" 760.Ed 761.Pp 762then mail sent to any of the addresses that the 763.Sq mylist 764alias expands to would have the sender's name set to 765.Qq List Maintainer . 766Mail sent to anyone at NetBSD.org other than 767.Sq friend@NetBSD.org 768would look like it was sent from 769.Sq anon@somewhere.net 770by 771.Qq Anon Ymous . 772Mail sent to 773.Sq friend@NetBSD.org 774would not have any sendmail flags set (unless they are set by the 775.Ic \&~h 776escape). 777.It Ic source 778The 779.Ic source 780command reads commands from a file. 781.It Ic top 782Takes a message list and prints the top few lines of each. 783The number of lines printed is controlled by the variable 784.Ic toplines 785and defaults to five. 786.It Ic type 787.Pq Ic t 788A synonym for 789.Ic print . 790.It Ic unalias 791Takes a list of names defined by 792.Ic alias 793commands and discards the remembered groups of users. 794The group names no longer have any significance. 795.It Ic undelete 796.Pq Ic u 797Takes a message list and marks each message as 798.Ic not 799being deleted. 800.It Ic unread 801.Pq Ic unr 802Takes a message list and marks each message as 803.Em not 804having been read. 805.It Ic unset 806Takes a list of option names and discards their remembered values; 807the inverse of 808.Ic set . 809.It Ic view 810.Pq Ic vie 811Like 812.Ic print 813but has the opposite MIME decoding behavior. 814(See the 815.Ar mime-decode-message 816variable.) 817.It Ic visual 818.Pq Ic v 819Takes a message list and invokes the display editor on each message. 820.It Ic write 821.Pq Ic w 822Similar to 823.Ic save , 824except that 825.Em only 826the message body 827.Em ( without 828the header) is saved. 829Extremely useful for such tasks as sending and receiving source 830program text over the message system. 831.It Ic xit 832.Pq Ic x 833A synonym for 834.Ic exit . 835.It Ic z 836.Nm 837presents message headers in windowfuls as described under the 838.Ic headers 839command. 840You can move 841.Nm Ns Ap s 842attention forward to the next window with the 843.Ic \&z 844command. 845Also, you can move to the previous window by using 846.Ic \&z\&\- . 847.El 848.Ss Tilde/Escapes 849Here is a summary of the tilde escapes, which are used when composing 850messages to perform special functions. 851Tilde escapes are only recognized at the beginning of lines. 852The name 853.Dq Em tilde\ escape 854is somewhat of a misnomer since the actual escape character can be set 855by the option 856.Ic escape . 857.Bl -tag -width Ds 858.It Ic \&~! Ns Ar command 859Execute the indicated shell command, then return to the message. 860.It Ic \&~@ Op Ar filelist 861Add the files in the white-space delimited 862.Ar filelist 863to the attachment list. 864If 865.Ar filelist 866is omitted, edit the attachment list, possibly appending to it: For 867each file in the list the user is prompted to change its attachment 868data. 869Changing the filename to empty will delete it from the list. 870Upon reaching the end of the attachment list, the user is prompted for 871additional files to attach until an empty filename is given. 872Filenames containing white-space can only be added in this 873.Qq edit 874mode. 875.It Ic \&~a 876Inserts the autograph string from the sign= option into the message. 877.It Ic \&~A 878Inserts the autograph string from the Sign= option into the message. 879.It Ic \&~b Ns Ar name ... 880Add the given names to the list of carbon copy recipients but do not make 881the names visible in the Cc: line 882.Dq ( blind 883carbon copy). 884.It Ic \&~c Ns Ar name ... 885Add the given names to the list of carbon copy recipients. 886.It Ic \&~d 887Read the file 888.Dq Pa dead.letter 889from your home directory into the message. 890.It Ic \&~e 891Invoke the text editor on the message collected so far. 892After the editing session is finished, you may continue appending 893text to the message. 894.It Ic \&~f Ns Ar messages 895Read the named messages into the message being sent. 896If no messages are specified, read in the current message. 897Message headers currently being ignored (by the 898.Ic ignore 899or 900.Ic retain 901command) are not included. 902.It Ic \&~F Ns Ar messages 903Identical to 904.Ic \&~f , 905except all message headers are included. 906.It Ic \&~h 907Edit the message header fields, and the options passed to sendmail, by 908typing each one in turn and allowing the user to append text to the 909end or modify the field by using the current terminal erase and kill 910characters. 911If 912.Xr editline 3 913support is included, then that line editor is used. 914.It Ic \&~i Ns Ar string 915Inserts the value of the named option into the text of the message. 916.It Ic \&~m Ns Ar messages 917Read the named messages into the message being sent, indented by a 918tab or by the value of 919.Ar indentprefix . 920If no messages are specified, read the current message. 921Message headers currently being ignored (by the 922.Ic ignore 923or 924.Ic retain 925command) are not included. 926.It Ic \&~M Ns Ar messages 927Identical to 928.Ic \&~m , 929except all message headers are included. 930.It Ic \&~p 931Print out the message collected so far, prefaced by the message header 932fields. 933.It Ic \&~q 934Abort the message being sent, copying the message to 935.Dq Pa dead.letter 936in your home directory if 937.Ic save 938is set. 939.It Ic \&~x 940Exits as with \&~q, except the message is not saved in dead.letter. 941.It Ic \&~r Ns Ar filename 942.It Ic \&~\*[Lt] Ns Ar filename 943Reads the named file into the message. 944If the argument begins with 945.Sq \&! , 946the rest of the string is taken as an arbitrary system command and is 947executed, with the standard output inserted into the message. 948.It Ic \&~s Ns Ar string 949Cause the named string to become the current subject field. 950.It Ic \&~\&t Ns Ar name ... 951Add the given names to the direct recipient list. 952.It Ic \&~\&v 953Invoke an alternative editor (defined by the 954.Ev VISUAL 955option) on the message collected so far. 956Usually, the alternative editor will be a screen editor. 957After you quit the editor, you may resume appending 958text to the end of your message. 959.It Ic \&~w Ns Ar filename 960Write the message onto the named file. 961.It Ic \&~\&| Ns Ar command 962Pipe the message through the command as a filter. 963If the command gives no output or terminates abnormally, retain 964the original text of the message. 965The command 966.Xr fmt 1 967is often used as 968.Ic command 969to rejustify the message. 970.It Ic \&~: Ns Ar mail-command 971Execute the given mail command. 972Not all commands, however, are allowed. 973.It Ic \&~~ Ns Ar string 974Insert the string of text in the message prefaced by a single ~. 975If you have changed the escape character, then you should double 976that character in order to send it. 977.El 978.Ss Mail Options 979Options are controlled via 980.Ic set 981and 982.Ic unset 983commands. 984Options may be either binary, in which case it is only 985significant to see whether they are set or not; or string, in which 986case the actual value is of interest. 987The binary options include the following: 988.Bl -tag -width append 989.It Ar append 990Causes messages saved in 991.Ar mbox 992to be appended to the end rather than prepended. 993This should always be set (perhaps in 994.Pa /etc/mail.rc ) . 995.It Ar ask , Ar asksub 996Causes 997.Nm 998to prompt you for the subject of each message you send. 999If you respond with simply a newline, no subject field will be sent. 1000.It Ar askcc 1001Causes you to be prompted for additional carbon copy recipients at 1002the end of each message. 1003Responding with a newline indicates your 1004satisfaction with the current list. 1005.It Ar autoinc 1006Causes new mail to be automatically incorporated when it arrives. 1007Setting this is similar to issuing the 1008.Ic inc 1009command at each prompt, except that the current message is not 1010reset when new mail arrives. 1011.It Ar askbcc 1012Causes you to be prompted for additional blind carbon copy recipients 1013at the end of each message. 1014Responding with a newline indicates your 1015satisfaction with the current list. 1016.It Ar autoprint 1017Causes the 1018.Ic delete 1019command to behave like 1020.Ic dp 1021\- thus, after deleting a message, the next one will be typed 1022automatically. 1023.It Ar debug 1024Setting the binary option 1025.Ar debug 1026is the same as specifying 1027.Fl d 1028on the command line and causes 1029.Nm 1030to output all sorts of information useful for debugging 1031.Nm . 1032.It Ar dot 1033The binary option 1034.Ar dot 1035causes 1036.Nm 1037to interpret a period alone on a line as the terminator 1038of a message you are sending. 1039.It Ar hold 1040This option is used to hold messages in the system mailbox 1041by default. 1042.It Ar ignore 1043Causes interrupt signals from your terminal to be ignored and echoed as 1044@'s. 1045.It Ar ignoreeof 1046An option related to 1047.Ar dot 1048is 1049.Ar ignoreeof 1050which makes 1051.Nm 1052refuse to accept a control-D as the end of a message. 1053.Ar Ignoreeof 1054also applies to 1055.Nm 1056command mode. 1057.It Ar metoo 1058Usually, when a group is expanded that contains the sender, the sender 1059is removed from the expansion. 1060Setting this option causes the sender to be included in the group. 1061.It Ar noheader 1062Setting the option 1063.Ar noheader 1064is the same as giving the 1065.Fl N 1066flag on the command line. 1067.It Ar nosave 1068Normally, when you abort a message with two 1069.Tn RUBOUT 1070(erase or delete) 1071.Nm 1072copies the partial letter to the file 1073.Dq Pa dead.letter 1074in your home directory. 1075Setting the binary option 1076.Ar nosave 1077prevents this. 1078.It Ar quiet 1079Suppresses the printing of the version when first invoked. 1080.It Ar Replyall 1081Reverses the sense of 1082.Ic reply 1083and 1084.Ic Reply 1085commands. 1086.It Ar searchheaders 1087If this option is set, then a message-list specifier in the form 1088.Dq /x:y 1089will expand to all messages containing the substring 1090.Dq y 1091in the header field 1092.Dq x . 1093The string search is case insensitive. 1094If 1095.Dq x 1096is omitted, it will default to the 1097.Dq Subject 1098header field. 1099The form 1100.Dq /to:y 1101is a special case, and will expand 1102to all messages containing the substring 1103.Dq y 1104in the 1105.Dq To , 1106.Dq Cc , 1107or 1108.Dq Bcc 1109header fields. 1110The check for 1111.Dq to 1112is case sensitive, so that 1113.Dq /To:y 1114can be used to limit the search for 1115.Dq y 1116to just the 1117.Dq To: 1118field. 1119.It Ar verbose 1120Setting the option 1121.Ar verbose 1122is the same as using the 1123.Fl v 1124flag on the command line. 1125When mail runs in verbose mode, the actual delivery of messages is 1126displayed on the user's terminal. 1127.El 1128.Ss Option String Values 1129.Bl -tag -width Va 1130.It Ev EDITOR 1131Pathname of the text editor to use in the 1132.Ic edit 1133command and 1134.Ic \&~e 1135escape. 1136If not defined, then a default editor is used. 1137.It Ev LISTER 1138Pathname of the directory lister to use in the 1139.Ic folders 1140command. 1141Default is 1142.Pa /bin/ls . 1143.It Ev PAGER 1144Pathname of the program to use in the 1145.Ic more 1146command or when 1147.Ic crt 1148variable is set. 1149The default paginator 1150.Xr more 1 1151is used if this option is not defined. 1152.It Ev SHELL 1153Pathname of the shell to use in the 1154.Ic \&! 1155command and the 1156.Ic \&~! 1157escape. 1158A default shell is used if this option is not defined. 1159.It Ev VISUAL 1160Pathname of the text editor to use in the 1161.Ic visual 1162command and 1163.Ic \&~v 1164escape. 1165.It Va crt 1166The valued option 1167.Va crt 1168is used as a threshold to determine how long a message must 1169be before 1170.Ev PAGER 1171is used to read it. 1172If 1173.Va crt 1174is set without a value, then the height of the terminal screen 1175stored in the system is used to compute the threshold (see 1176.Xr stty 1 ) . 1177.It Ar el-completion-keys 1178A comma or space delimited list of keys to do 1179.Xr editline 3 1180completion. 1181For example 1182.Nm set el-completion-keys=^I,^D 1183will bind completion to both the tab and CTRL-D keys. 1184(Requires 1185.Xr editline 3 1186support.) 1187.It Ar el-editor 1188The line editing mode: must be 1189.Dq emacs 1190or 1191.Dq vi . 1192If unset, editing is not enabled. 1193(Requires 1194.Xr editline 3 1195support.) 1196.It Ar el-history-size 1197The number of lines of history to remember. 1198If unset, history is not enable. 1199(Requires 1200.Xr editline 3 1201support.) 1202.It Ar escape 1203If defined, the first character of this option gives the character to 1204use in the place of 1205.Sq ~ 1206to denote escapes. 1207.It Ar folder 1208The name of the directory to use for storing folders of 1209messages. 1210If this name begins with a 1211.Sq / , 1212.Nm 1213considers it to be an absolute pathname; otherwise, the 1214folder directory is found relative to your home directory. 1215.It Ar hdronly-format 1216If set, use this format string for output when in headers only mode 1217.Pq Fl H . 1218Otherwise, use the 1219.Ar header-format 1220string. 1221The format syntax is the same as for 1222.Ar header-format . 1223For example, the following 1224.Bd -literal -offset 0 1225set hdronly-format="%P%Q%3i \&%-21.20f \&%m/%d %R %3K \\"%q\\"" 1226.Ed 1227.Pp 1228might be used to get slightly a shorter header string that might make 1229it through a pipe without getting folded. 1230.It Ar header-format 1231If set, use this format string when displaying headers in command 1232mode. 1233The format string supports the following conversions in addition to 1234those of 1235.Xr strftime 3 : 1236.Pp 1237.Bl -tag -width ".Ar \&%?key?" -compact 1238.It Ar \&%?key? 1239The header field with name 1240.Sq key . 1241Note: if key[0] is 1242.Sq \&- , 1243ignore the 1244.Sq \&- 1245and extract the address 1246portion of the field (i.e., 1247.Sq skin 1248the field). 1249.It Ar \&%J 1250The number of header lines in the message. 1251.It Ar \&%K 1252The number of body lines in the message. 1253.It Ar \&%L 1254The total number of lines in the message. 1255.It Ar \&%N 1256The sender's full name (as in the "From:" or "Sender:" fields). 1257.It Ar \&%O 1258The message size. 1259.It Ar \&%P 1260The current 1261.Qq dot 1262.Pq Sq \*[Gt] 1263messsage. 1264.It Ar \&%Q 1265The message status flag. 1266.It Ar \&%Z 1267The time zone name (if it exists). 1268.It Ar \&%f 1269The email address of sender. 1270.It Ar \&%i 1271The message number. 1272.It Ar \&%n 1273The sender's login name (taken from the address). 1274.It Ar \&%q 1275The subject. 1276.It Ar \&%t 1277The total number of messages. 1278.It Ar \&%z 1279The GMT offset (if found). 1280.El 1281.Pp 1282If the format string begins with 1283.Qq \&%?? 1284then the date will be extracted from the headline. 1285Otherwise it will be extracted from the 1286.Ar Date: 1287header falling back to the headline if that extraction fails. 1288For example, the default format is: 1289.Bd -literal -offset 0 1290set header-format \&"\&%??%P%Q%3i \&%-21.20f \&%a \&%b \&%e \&%R \&%3K/%-5O \&\\"%q\\"" 1291.Ed 1292.Pp 1293Note: 1294.Ar \&%n 1295and 1296.Ar \&%t 1297as used by 1298.Xr strftime 3 1299were redundant with \\t and \\n, respectively, so nothing is lost 1300using them here. 1301.It Ar indentpreamble 1302If set, this format string will be inserted before quoting a message 1303.Po Ic \&~m 1304or 1305.Ic \&~M 1306.Pc . 1307The format syntax is the same as for 1308.Ar header-format . 1309For example, the following: 1310.Bd -literal -offset 0 1311set indentpreamble=\&"On \&%b \&%e \&%T, \&%Y \&%z (%Z), \&%n (%.50N) wrote:\\n-- Subject: \&%.65q\\n" 1312.Ed 1313.Pp 1314would insert something like 1315.Bd -literal -offset 0 1316On Oct 27 11:00:07, 2006 -0400 (EDT), anon (Anon Ymous) wrote: 1317-- Subject: suggestions for mail(1) 1318.Ed 1319.Pp 1320before the quoted message. 1321.It Ar indentprefix 1322String used by the 1323.Dq ~m 1324tilde escape for indenting messages, in place of 1325the normal tab character 1326.Pq Sq ^I . 1327Be sure to quote the value if it contains 1328spaces or tabs. 1329.It Ar indentpostscript 1330If set, this format string will be inserted after quoting a message 1331.Po Ic \&~m 1332or 1333.Ic \&~M 1334.Pc . 1335The format syntax is the same as for 1336.Ar header-format . 1337For example, the following: 1338.Bd -literal -offset 0 1339set indentpostscript="-- End of excerpt from \&%.50N" 1340.Ed 1341.Pp 1342would insert something like 1343.Bd -literal -offset 0 1344-- End of excerpt from Anon Ymous 1345.Ed 1346.Pp 1347after the quoted message. 1348.It Ar mime-attach-list 1349If set, the command line flag 1350.Fl a 1351will accept a whitespace delimited list of files. 1352Otherwise, its argument is interpreted as a single filename. 1353Warning: If enabled, care must be taken to properly quote files that 1354contain whitespace, both from the shell and from this second expansion 1355done by 1356.Nm . 1357.It Ar mime-body-TYPE-SUBTYPE 1358MIME-hook for the body of a MIME block of 1359.Qq Content-Type: TYPE/SUBTYPE . 1360(See 1361.Sy MIME Enhancements 1362below.) 1363.It Ar mime-charset 1364Convert Content-type: 1365.Sq text 1366messages to this character set or 1367.Qq us-ascii 1368if the value is empty. 1369If unset, no character set conversion is done. 1370.It Ar mime-decode-header 1371If set, decode the headers along with the body when 1372.Ar mime-decode-message 1373is set. 1374The header decode follows the same rulse as the body (see 1375.Ar mime-decode-message ) . 1376.It Ar mime-decode-insert 1377When inserting 1378a message into the mail buffer 1379.Po Ic \&~f 1380or 1381.Ic \&~F 1382.Pc , 1383the text inserted will be decoded according to the settings of the 1384.Ar mime-decode-message 1385and 1386.Ar mime-decode-header 1387variables. 1388.It Ar mime-decode-message 1389This determines the MIME decoding behavior of the basic display 1390commands 1391.Ic More , 1392.Ic more , 1393.Ic Page , 1394.Ic page , 1395.Ic Print , 1396.Ic print , 1397.Ic Type , 1398and 1399.Ic type . 1400If unset, these commands do not do MIME decoding. 1401If set but empty, the commands do MIME decoding. 1402Otherwise, it lists which of these commands do MIME decoding. 1403The list is comma or blank delimited and case insensitive, so the 1404capitalized and lowercase versions of a command have the same MIME 1405decoding behavior. 1406Recall that the 1407.Ic View 1408and 1409.Ic view 1410commands always have the opposite MIME decoding behavior as the 1411.Ic Print 1412and 1413.Ic print 1414commands. 1415.It Ar mime-decode-quote 1416When quoting 1417a message into the mail buffer 1418.Po Ic \&~m 1419or 1420.Ic \&~M 1421.Pc , 1422the text inserted will be decoded according to the settings of the 1423.Ar mime-decode-message 1424and 1425.Ar mime-decode-header 1426variables. 1427.It Ar mime-encode-message 1428If set, encode the body of the message as required. 1429Typically, this is just an issue of whether "quoted-printable" 1430encoding is used or not. 1431If it has a value, then use it to determine the encoding type. 1432Allowed values are 1433.Qq 7bit , 1434.Qq 8bit , 1435.Qq binary , 1436.Qq quoted-printable , 1437or 1438.Qq base64 . 1439.It Ar mime-head-TYPE-SUBTYPE 1440MIME-hook for the header of a MIME block of 1441.Qq Content-Type: TYPE/SUBTYPE . 1442(See 1443.Sy MIME Enhancements 1444below.) 1445.It Ar mime-hook-TYPE-SUBTYPE 1446MIME-hook for MIME block of 1447.Qq Content-Type: TYPE/SUBTYPE . 1448(See 1449.Sy MIME Enhancements 1450below.) 1451.It Ev MBOX 1452The name of the 1453.Ar mbox 1454file. 1455It can be the name of a folder. 1456The default is 1457.Dq Li mbox 1458in the user's home directory. 1459.It Ar prompt 1460If defined, it specifies the prompt to use when in command mode. 1461Otherwise, the default 1462.Qq &\ 1463is used. 1464The format syntax is the same as for 1465.Ar header-format . 1466.It Ar record 1467If defined, gives the pathname of the file used to record all outgoing 1468mail. 1469If not defined, then outgoing mail is not so saved. 1470.It Ar ReplyAsRecipient 1471This is used when replying to email (see the 1472.Ic reply 1473or 1474.Ic Reply 1475commands). 1476It is useful if you have multiple email addresses and wish to ensure 1477that replies respect them. 1478If set, grab the email address(es) from the 1479.Dq To: 1480field of the message being replied to. 1481If there is only one such address, and if it does not match any 1482address in the value of 1483.Ar ReplyAsRecipient 1484(a comma or space delimited list of addresses, possibly empty), then 1485use this address in the "From:" field of the reply. 1486This is accomplished by passing the address to 1487.Xr sendmail 1 1488with the 1489.Fl f 1490option. 1491Note: the sendmail options can be edited with the 1492.Ic \&~h 1493escape. 1494.It Ar smopts-verify 1495Verify the sendmail options used on outgoing mail if they were obtained from a 1496.Ar smopts 1497match. 1498This has no effect if there are no sendmail flags or if the flags 1499were set by the 1500.Ic \&~h 1501escape. 1502.It Ar toplines 1503If defined, gives the number of lines of a message to be printed out 1504with the 1505.Ic top 1506command; normally, the first five lines are printed. 1507.El 1508.Ss MIME Enhancements 1509A MIME message is (recursively) divided into a series of MIME parts 1510that can be thought of as sub-messages, each with a header and body. 1511When MIME support is enabled (by setting 1512.Ar mime-decode-message ) , 1513.Nm 1514splits a message into a series of its smallest MIME parts and 1515processes those parts as if they were messages themselves, passing the 1516header and body through a pipeline of the form: 1517.Pp 1518.Dl mail -\*[Gt] MIME-decoder -\*[Gt] MIME-hook -\*[Gt] pager -\*[Gt] screen 1519.Pp 1520The 1521.Em MIME-decoder 1522decodes 1523.Qq base64 1524or 1525.Qq quoted-printable 1526encoding and is enabled according to the 1527.Qq Content-Transfer-Encoding: 1528of the part. 1529The 1530.Em MIME-hook 1531is an external program to further process the part (see below). 1532The 1533.Em pager 1534is the program that pages the message 1535(see 1536.Va PAGER ) . 1537Any of these intermediate pipe stages may be missing and/or different 1538for the head and body of each MIME part. 1539Certain 1540.Qq Content-Types: 1541may disable the entire pipeline (e.g., 1542.Qq application/octet ) . 1543.Pp 1544The 1545.Em MIME-hook 1546stage is not present unless one of the following variables is set: 1547.Bd -literal -offset indent 1548mime-hook-TYPE-SUBTYPE - applies to the entire MIME part 1549mime-head-TYPE-SUBTYPE - applies to the header of the MIME part 1550mime-body-TYPE-SUBTYPE - applies to the body of the MIME part 1551.Ed 1552.Pp 1553where TYPE and SUBTYPE are the Content-Type type and subtype 1554(respectively) of the MIME part to which the hook applies. 1555If the 1556.Dq -SUBTYPE 1557is missing, any subtype is matched. 1558The value of these variables has the format: 1559.Bd -filled -offset indent 1560.Op Ar flags 1561.Ar command 1562.Ed 1563.Pp 1564where the 1565.Ar command 1566is expected to read from stdin and writes to stdout, and the possible 1567flags are 1568.Bl -tag -width Ds -offset indent 1569.It ! 1570Execute 1571.Ar command 1572in a sub-shell rather than doing an 1573.Xr exec 3 1574(see 1575.Va Shell ) . 1576This is necessary for shell scripts. 1577.It + 1578Use this hook when selecting the part to display in a 1579.Qq multipart/alternative 1580block. 1581Multipart blocks contain 1582.Qq alternative 1583versions with the same information, in increasing order of preference 1584(and decoding complexity). 1585The last one the mail agent understands is the one to be displayed. 1586This is typically used for sending a message in both 1587.Qq plain text 1588and 1589.Qq html , 1590but more complex subtypes are also possible. 1591.It - 1592Do not decode before executing 1593.Ar command . 1594.El 1595.Pp 1596If your 1597.Ar command 1598begins with one of these flags, precede it with a space to signal the 1599end of the flags. 1600.Pp 1601WARNING: automatically running a program is a potential security risk 1602if that program has bugs, so be careful what you run. 1603.Pp 1604.Em Examples : 1605View all "Content-Type: image/jpeg" parts with 1606.Xr xv 1 1607(assuming it is installed): 1608.Pp 1609.Dl set mime-body-image-jpeg="/usr/pkg/bin/xv -" 1610.Pp 1611Decode all "Content-Type: images/*" blocks with 1612.Xr uudeview 1 1613(assuming it is installed), placing the results in 1614.Pa /tmp : 1615.Pp 1616.Dl set mime-hook-image="-/usr/pkg/bin/uudeview -p /tmp -i -a +o -q -" 1617.Pp 1618Read all "Content-Type: text/html" parts using 1619.Xr lynx 1 1620(assuming it is installed) and add this support to 1621multipart/alternative blocks: 1622.Pp 1623.Bd -literal -offset indent 1624set mime-body-text-html="+/usr/pkg/bin/lynx -force_html -dump -stdin" 1625.Ed 1626.Pp 1627Generally, the incoming mail will have a better 1628.Qq plain/text 1629alternative. 1630.Sh ENVIRONMENT 1631.Nm 1632uses the 1633.Ev HOME , 1634.Ev TMPDIR , 1635and 1636.Ev USER 1637environment variables. 1638.Sh FILES 1639.Bl -tag -width /usr/share/misc/mail.*help -compact 1640.It Pa /var/mail/* 1641Post office. 1642.It ~/mbox 1643User's old mail. 1644.It ~/.mailrc 1645File giving initial mail commands. 1646This can be overridden by setting the 1647.Ev MAILRC 1648environment variable. 1649.It Pa /tmp/mail.R* 1650Temporary files. 1651.It Pa /usr/share/misc/mail.*help 1652Help files. 1653.It Pa /etc/mail.rc 1654System initialization file. 1655.El 1656.Sh SEE ALSO 1657.Xr fmt 1 , 1658.Xr newaliases 1 , 1659.Xr sendmail 1 , 1660.Xr vacation 1 , 1661.Xr aliases 5 , 1662.Xr mailaddr 7 1663and 1664.Rs 1665.%T "The Mail Reference Manual" 1666.Re 1667.Sh HISTORY 1668A 1669.Nm 1670command 1671appeared in 1672.At v6 . 1673This man page is derived from 1674.%T "The Mail Reference Manual" 1675originally written by Kurt Shoens. 1676.Sh BUGS 1677There are some flags that are not documented here. 1678Most are not useful to the general user. 1679.Pp 1680Usually, 1681.Nm 1682is just a link to 1683.Nm Mail , 1684which can be confusing. 1685.Pp 1686The name of the 1687.Ic alternates 1688list is incorrect English (it should be 1689.Dq alternatives ) , 1690but is retained for compatibility. 1691.Pp 1692There must be sufficient space on $TMPDIR for various temporary files. 1693.Pp 1694If an unrecoverable character set conversion error occurs (during 1695display), the message is truncated and a warning is printed. 1696This seems to be rare, but probably the remainder of the message 1697should be printed without conversion. 1698