1.\" $NetBSD: mail.1,v 1.69 2021/11/01 20:40:08 rillig 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 December 14, 2019 33.Dt MAIL 1 34.Os 35.Sh NAME 36.Nm mail , 37.Nm mailx 38.Nd send and receive mail 39.Sh SYNOPSIS 40.Nm 41.Op Fl EIinv 42.Op Fl a Ar file 43.Op Fl b Ar bcc-addr 44.Op Fl c Ar cc-addr 45.Op Fl r Ar rcfile 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 colon-modifier 52.Fl f 53.Op Ar name 54.Nm 55.Op Fl EIiNnv 56.Op Fl H Ns Op colon-modifier 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.Bl -tag -width flag 65.It Fl a 66Attach 67.Ar file 68to the message. 69.It Fl b 70Send blind carbon copies to 71.Ar list . 72List should be a comma-separated list of names. 73.It Fl c 74Send carbon copies to 75.Ar list 76of users. 77.It Fl E 78Don't send messages with an empty body. 79This is useful for piping errors from cron scripts. 80.It Fl f 81Read in the contents of your 82.Ar mbox 83(or the specified file) 84for processing; when you 85.Ic quit , 86.Nm 87writes undeleted messages back to this file. 88.It Fl H 89Print the header summaries and exit. 90The optional colon-modifier string must begin with a 91.Ql \&: 92and be followed by one or more of the characters described in the 93.Sx Specifying messages 94section below. 95E.g., 96.Do 97.Nm 98.Fl H Ns :n 99.Dc 100will display just new message headers. 101.It Fl I 102Forces mail to run in interactive mode even when 103input isn't a terminal. 104In particular, the 105.Ic \&~ 106special 107character when sending mail is only active in interactive mode. 108.It Fl i 109Ignore tty interrupt signals. 110This is particularly useful when using 111.Nm 112on noisy phone lines. 113.It Fl N 114Inhibits the initial display of message headers 115when reading mail or editing a mail folder. 116.It Fl n 117Inhibits reading 118.Pa /etc/mail.rc 119upon startup. 120.It Fl r 121Specify an alternate user rcfile to load. 122This overrides the value specified in the environment variable 123.Ev MAILRC 124which in turn overrides the default 125.Pa ~/.mailrc 126file. 127.It Fl s 128Specify subject on command line 129(only the first argument after the 130.Fl s 131flag is used as a subject; be careful to quote subjects 132containing spaces.) 133.It Fl u 134Is equivalent to: 135.Pp 136.Dl mail -f /var/mail/user 137.It Fl v 138Verbose mode. 139The details of delivery are displayed on the user's terminal. 140.El 141.Ss Sending mail 142To send a message to one or more people, 143.Nm 144can be invoked with arguments which are the names of people to 145whom the mail will be sent. 146You are then expected to type in your message, followed by a 147.Ql control-D 148at the beginning of a line. 149.Pp 150Any flags following the list of recipients, will be passed, together 151with their arguments, directly to 152.Xr sendmail 1 . 153For example to change your 154.Dv From 155address to 156.Dv somebody@somewhere.net 157you can specify: 158.Pp 159.Dl mail recipient -f somebody@somewhere.net 160.Pp 161To prevent multiple copies of a message being sent to the same 162address, duplicate addresses (after alias expansion) are removed from 163the 164.Ar bcc-addr , 165.Ar cc-addr , 166and 167.Ar to-addr 168lists. 169In addition, addresses on the 170.Ar cc-addr 171and 172.Ar to-addr 173lists are removed if they occur on the 174.Ar bcc-addr 175list and addresses on the 176.Ar cc-addr 177list are removed if they occur on the 178.Ar to-addr 179list. 180If the 181.Ar to-addr 182list is empty after these deletions, most systems will insert the line 183.Dq To: undisclosed recipients:; . 184.Pp 185The section below 186.Sx Replying to or originating mail , 187describes some features of 188.Nm 189available to help you compose your letter. 190.Ss Reading mail 191In normal usage 192.Nm 193is given no arguments and checks your mail out of the post office, 194then prints out a one line header of each message found. 195The current message is initially the first message (numbered 1) 196and can be printed using the 197.Ic print 198command (which can be abbreviated 199.Ic p ) . 200You can move among the messages much as you move between lines in 201.Xr \&ed 1 , 202with the commands 203.Ic \&+ 204and 205.Ic \&\- 206moving backwards and forwards, and simple numbers. 207.Ss Disposing of mail 208After examining a message you can 209.Ic delete 210.Pq Ic d 211the message or 212.Ic reply 213.Pq Ic r 214to it. 215Deletion causes the 216.Nm 217program to forget about the message. 218This is not irreversible; the message can be 219.Ic undeleted 220.Pq Ic u 221by giving its number, or the 222.Nm 223session can be aborted by giving the 224.Ic exit 225.Pq Ic x 226command. 227Deleted messages will, however, usually disappear never to be seen again. 228.Ss Specifying messages 229Many commands (e.g., 230.Ic delete , 231.Ic from , 232and 233.Ic print ) 234accept a list of messages as an argument. 235Messages may be specified by their message number, by a range of 236messages, or by a pattern string matching certain fields in the header 237as described below. 238These message 239.Dq specs 240may be combined by the usual binary boolean operations 241.Ql & , 242.Ql \&| , 243and 244.Ql \&^ , 245which denote, respectively, a logical 246.Dq and , 247.Dq or , 248and 249.Dq xor . 250Logical expressions may be grouped with parentheses 251.Ql \&( 252and 253.Ql \&) 254and 255negated with 256.Ql \&! . 257If the binary operator is missing between two message specs, it is 258assumed to be a 259.Ql \&| . 260This is for simplicity, backwards compatibility, and also to 261facilitate using the 262.Ql \&| 263symbol to denote a pipe. 264(See 265.Ar enable-pipes . ) 266.Pp 267Besides the obvious (base10) message numbers, the characters 268.Ql \&^ , 269.Ql \&- , 270.Ql \&. , 271.Ql \&+ , 272and 273.Ql \&$ 274denote, respectively, the first message, the message before the 275.Dq dot 276.Pq the current message , 277the 278.Dq dot 279message, the message following the 280.Dq dot , 281and the last message. 282.Pp 283A 284.Dq message range 285consists of two message numbers separated by a 286.Ql \&- . 287A 288.Ql \&* 289denotes all messages and is equivalent to 290.Ql ^-$ . 291.Pp 292A pattern is a string (not beginning with any of the above special 293characters). 294If it does not begin with a 295.Ql \&/ , 296it is compared with the senders address. 297If it begins with a 298.Ql \&/ , 299and 300.Ar searchheaders 301is not defined, the remainder of the string is compared with the 302subject field. 303(See 304.Ar searchheaders 305for searching other header fields or the message body.) 306If 307.Ar regex-search 308is not defined, then the comparison is a simple case insensitive 309substring match. 310(See 311.Ar regex-search 312for regular expression matches.) 313.Pp 314A list of messages may be restricted by a 315.Dq colon-modifier 316string, i.e., a 317.Ql \&: 318followed by one or more of the characters: 319.Bd -literal -offset indent 320d deleted 321e edited 322m mboxed 323n new 324o old 325p preserved 326r read 327s saved 328t tagged 329u unread and not new 330! invert the meaning of the colon-modifiers 331.Ed 332.Pp 333If there are no address specifications other than colon-modifiers, 334the colon-modifiers apply to all messages. 335Thus 336.Dq Li from netbsd :n 337would display the headers of all new messages with 338.Ql netbsd 339in the sender's address, while 340.Dq Li from :!r 341and 342.Dq Li from :nu 343would both display all new and unread messages. 344Multiple colon-modifiers may be specified and a single 345.Ql \&: 346with no letters following indicates the colon-modifier from the 347preceding command. 348.Pp 349For example: 350.Bd -literal -offset indent 351from 1 12 3-5 352.Ed 353.Pp 354would display the headers from messages 1, 3, 4, 5, and 12. 355.Bd -literal -offset indent 356from anon & ( /foo | /bar ) 357.Ed 358.Pp 359would display all headers that had 360.Ql anon 361in the sender's address and either 362.Ql foo 363or 364.Ql bar 365in the subject line. 366.Pp 367Generally, commands cannot select messages that are not displayed, 368such as deleted or hidden messages, the exception being the 369.Ic undelete 370command. 371.Ss Replying to or originating mail 372You can use the 373.Ic reply 374command to set up a response to a message, sending it back to the 375person who it was from. 376Text you then type in, up to an end-of-file, 377defines the contents of the message. 378While you are composing a message, 379.Nm 380treats lines beginning with the character 381.Ic \&~ 382specially. 383For instance, typing 384.Ic \&~m 385(alone on a line) will place a copy 386of the current message into the response right shifting it by a tab stop 387(see 388.Em indentprefix 389variable, below). 390Other escapes will set up subject fields, add and delete recipients 391to the message, and allow you to escape to an editor to revise the 392message or to a shell to run some commands. 393(These options are given in the summary below.) 394.Ss Ending a mail processing session 395You can end a 396.Nm 397session with the 398.Ic quit 399.Pq Ic q 400command. 401Messages which have been examined go to your 402.Ar mbox 403file unless they have been deleted in which case they are discarded. 404Unexamined messages go back to the post office. 405(See the 406.Fl f 407option above). 408.Ss Personal and system wide distribution lists 409It is also possible to create personal distribution lists so that, 410for instance, you can send mail to 411.Dq Li cohorts 412and have it go 413to a group of people. 414Such lists can be defined by placing a line like 415.Pp 416.Dl alias cohorts bill ozalp jkf mark kridle@ucbcory 417.Pp 418in the file 419.Pa \&.mailrc 420in your home directory. 421The current list of such aliases can be displayed with the 422.Ic alias 423command in 424.Nm . 425System wide distribution lists can be created by editing 426.Pa /etc/mail/aliases , 427see 428.Xr aliases 5 429and 430.Xr sendmail 1 ; 431these are kept in a different syntax. 432In mail you send, personal aliases will be expanded in mail sent 433to others so that they will be able to 434.Ic reply 435to the recipients. 436System wide 437.Ic aliases 438are not expanded when the mail is sent, 439but any reply returned to the machine will have the system wide 440alias expanded as all mail goes through 441.Xr sendmail 1 . 442.Ss Network mail (ARPA, UUCP, Berknet) 443See 444.Xr mailaddr 7 445for a description of network addresses. 446.Pp 447.Nm 448has a number of options which can be set in the 449.Pa .mailrc 450file to alter its behavior; thus 451.Dq Li set askcc 452enables the 453.Ar askcc 454feature. 455(These options are summarized below.) 456.Sh SUMMARY 457(Adapted from the 458.Dq Mail Reference Manual ) 459.Pp 460Each command is typed on a line by itself, and may take arguments 461following the command word. 462The command need not be typed in its 463entirety \- the first command which matches the typed prefix is used. 464For commands which take message lists as arguments, if no message 465list is given, then the next message forward which satisfies the 466command's requirements is used. 467If there are no messages forward of the current message, the search 468proceeds backwards, and if there are no good messages at all, 469.Nm 470types 471.Dq Li \&No applicable messages 472and aborts the command. 473.Bl -tag -width delete 474.It Ic \&! 475Executes the shell 476(see 477.Xr sh 1 478and 479.Xr csh 1 ) 480command which follows. 481.It Ic \&\- 482Print out the preceding message. 483If given a numeric 484argument 485.Ar n , 486goes to the 487.Ar n Ap th 488previous message and prints it. 489.It Ic \&= 490With no argument, it displays the current message number. 491Otherwise, set the current message number to its first argument. 492.It Ic \&? 493Prints a brief summary of commands. 494.It Ic \&| 495Pipe the current message body through the shell 496(see 497.Xr sh 1 498and 499.Xr csh 1 ) 500command which follows. 501.It Ic Detach 502Like 503.Ic detach 504but also saves MIME parts that don't have a filename associated with 505them. 506For the unnamed parts, a filename is suggested containing the message 507and part numbers, and the subtype. 508.It Ic Header 509.Pq Ic H 510Specify or show additional header fields. 511This is intended for adding extra header fields like 512.Dq Reply-To: 513or 514.Dq X-Organization: 515to the header. 516For example: 517.Bd -literal -offset 0 518 Header X-Mailer: NetBSD mail(1) 9.1 519.Ed 520.Pp 521would add the 522.Dq X-Mailer: NetBSD mail(1) 9.1 523line to the message header. 524Without any arguments, the extra header fields are displayed. 525With only a header name (including the 526.Sq \&: ) , 527it will delete all extra header fields with that name. 528Note: Although some syntax checking is done on the header line, care 529should be taken to ensure that it complies with RFC 2821 and 2822. 530Also, the extra header lines are not currently displayed by the 531.Ic \&~h 532tilde command when sending mail (use 533.Ic \&~:Header 534to see them). 535.It Ic More 536.Pq Ic M 537Like 538.Ic more 539but also prints out ignored header fields. 540.It Ic Page 541.Pq Ic \&Pa 542A synonym for 543.Ic More . 544.It Ic Print 545.Pq Ic P 546Like 547.Ic print 548but also prints out ignored header fields. 549See also 550.Ic print , 551.Ic more , 552.Ic page , 553.Ic type , 554.Ic view , 555.Ic ignore , 556and 557.Ic retain . 558.It Ic Reply 559.Pq Ic R 560Reply to originator. 561Does not reply to other recipients of the original message. 562(See 563.Ic reply . ) 564.It Ic Save 565.Pq Ic S 566Same as 567.Ic save 568except that all header fields are saved ignoring the 569.Ic saveignore 570or 571.Ic saveretain 572lists. 573.It Ic Type 574.Pq Ic T 575Identical to the 576.Ic Print 577command. 578.It Ic View 579.Pq Ic V 580Like 581.Ic Print 582but has the opposite MIME decoding behavior. 583(See the 584.Ar mime-decode-message 585variable.) 586.It Ic alias 587.Pq Ic a 588With no arguments, prints out all currently-defined aliases. 589With one argument, prints out that alias. 590With more than one argument, creates 591a new alias or changes an old one. 592.It Ic alternates 593.Pq Ic alt 594The 595.Ic alternates 596command is useful if you have accounts on several machines. 597It can be used to inform 598.Nm 599that the listed addresses are really you. 600When you 601.Ic reply 602to messages, 603.Nm 604will not send a copy of the message to any of the addresses 605listed on the 606.Ic alternates 607list. 608If the 609.Ic alternates 610command is given with no argument, the current set of alternative 611names is displayed. 612.It Ic bounce 613Takes a list of messages and prompts for an address to bounce the 614messages to. 615If no message is specified, the current message is used. 616All the original header fields are preserved except for the 617.Ql Delivered-To , 618.Ql X-Original-To 619and 620.Ql Status 621fields. 622The new 623.Ql To 624field contains the bounce address(es) plus any addresses in the old 625.Ql To 626field minus the user's local address and any on the alternates list. 627(See the 628.Ic alternates 629command.) 630.It Ic chdir 631.Pq Ic c 632Changes the user's working directory to that specified, if given. 633If no directory is given, then changes to the user's login directory. 634.It Ic copy 635.Pq Ic co 636The 637.Ic copy 638command does the same thing that 639.Ic save 640does, except that it does not mark the messages it 641is used on for deletion when you quit. 642.It Ic deldups 643Delete duplicate messages based on their 644.Ql Message-Id 645field, keeping the first one in the current sort order. 646This can be useful with replies to a mailing list that are also CCed 647to a subscriber. 648(The same thing can also be accomplished with the threading and 649tagging commands.) 650.It Ic delete 651.Pq Ic d 652Takes a list of messages as an argument and marks them all as deleted. 653Deleted messages will not be saved in 654.Ar mbox , 655nor will they be available for most other commands. 656.It Ic detach 657Takes a message list followed by a target directory as arguments, 658decodes each MIME part in the message list, and saves it in the target 659directory. 660If the message list is empty, use the current message. 661If the directory is not specified, use the directory specified by 662.Ar mime-detach-dir 663variable and, if that is empty, default to the directory 664.Nm 665was started in. 666For each MIME part in the message list, the filename is displayed for 667confirmation or changes. 668If an empty name is entered, the part is skipped. 669If the filename already exists, the user will be prompted before 670overwriting it. 671(See the 672.Ar mime-detach-batch 673and 674.Ar mime-detach-overwrite 675variables to change this behavior.) 676Only MIME parts with an associated filename in the 677.Ql Content-Type 678or 679.Ql Content-Disposition 680fields are decoded. 681(See 682.Ic Detach 683to detach all parts.) 684The MIME extension hooks and character set conversion are ignored. 685.It Ic dp 686(also 687.Ic dt ) 688Deletes the current message and prints the next message. 689If there is no next message, 690.Nm 691says 692.Dq Li "at EOF" . 693.It Ic down 694Go down one level in the thread. 695If given a message number, it descends the thread below that message, 696otherwise it descends from the current message (dot). 697.It Ic edit 698.Pq Ic e 699Takes a list of messages and points the text editor at each one in 700turn. 701On return from the editor, the message is read back in. 702.It Ic else 703Switch the command execution condition set by the previous 704.Ic if , 705.Ic ifdef , 706or 707.Ic ifndef 708command. 709.It Ic endif 710Terminate an 711.Ic if , 712.Ic ifdef , 713or 714.Ic ifndef 715command. 716.It Ic exit 717.Po Ic ex 718or 719.Ic x 720.Pc 721Effects an immediate return to the Shell without 722modifying the user's system mailbox, his 723.Ar mbox 724file, or his edit file in 725.Fl f . 726.It Ic expandaddr 727If unset (the default), recipient addresses must be names of local mailboxes 728or Internet mail addresses. 729If set, shell expansion of existing mailbox names will be performed. 730.It Ic expose 731Expose the thread structure so all messages appear in header listings. 732(See 733.Ar hide 734for the inverse.) 735The default header prompt will indent each header line one space for 736each level in the threading. 737The 738.Dq Li "%?* ?" 739format string does this. 740.It Ic file 741.Pq Ic fi 742The same as 743.Ic folder . 744.It Ic flatten 745For each message number in the argument list, or the current thread if 746no message list is given, promote all exposed children to the same 747thread level. 748.It Ic folders 749List the names of the folders in your folder directory. 750.It Ic folder 751.Pq Ic fo 752The 753.Ic folder 754command switches to a new mail file or folder. 755With no arguments, it tells you which file you are currently reading. 756If you give it an argument, it will write out changes (such 757as deletions) you have made in the current file and read in 758the new file. 759Some special conventions are recognized for the name. 760.Ql # 761means the previous file, 762.Ql % 763means your system mailbox, 764.Ql %user 765means user's system mailbox, 766.Ql & 767means your 768.Ar mbox 769file, and 770.Ql +file 771means a file in your folder directory. 772.It Ic forward 773Takes a list of messages and prompts for an address (or addresses) to 774forward each message to. 775If no message list is specified, the current message is used. 776The mail editor is run for each message allowing the user to enter a 777message that will precede the forward message. 778The message is sent as a multipart/mixed MIME encoded message. 779All header fields except the 780.Ql Status 781field are included. 782.It Ic from 783.Pq Ic f 784Takes a list of messages and prints their message headers. 785.It Ic headers 786.Pq Ic h 787Lists the current range of headers, which is an 18\-message group. 788If a 789.Ql \&+ 790argument is given, then the next 18\-message group is printed, and 791if a 792.Ql \&\- 793argument is given, the previous 18\-message group is printed. 794.It Ic help 795A synonym for 796.Ic \&? 797.It Ic hide 798Collapse the threads so that only the head of each thread is shown, 799hiding the subthreads. 800(See 801.Ar expose 802for the inverse.) 803.It Ic hidetags 804Restrict the display to untagged messages. 805In threaded mode, subthreads that connect directly to an untagged 806message are also displayed, including tagged messages in the 807connecting chain. 808.It Ic hidethreads 809The same as 810.Ar hide . 811.It Ic hold 812.Po Ic ho , 813also 814.Ic preserve 815.Pc 816Takes a message list and marks each message therein to be saved in 817the user's system mailbox instead of in 818.Ar mbox . 819Does not override the 820.Ic delete 821command. 822.It Ic if 823Execute commands that follow depending on the operating mode. 824The current supported modes are 825.Ql receiving , 826.Ql sending , 827and 828.Ql headersonly . 829For example, one use might be something like: 830.Bd -literal -offset 0 831if headersonly 832 set header-format="%P%Q%3i %-21.20f %m/%d %R %3K \e"%q\e"" 833else 834 set header-format="%P%Q%?& ?%3i %-21.20f %a %b %e %R %3K/%-5O \e"%q\e"" 835endif 836.Ed 837.It Ic ifdef 838Execute commands that follow if the specified variable is defined. 839Note: This includes environment variables. 840.It Ic ifndef 841Execute commands that follow if the specified variable is not 842defined. 843.It Ic ignore 844Add the list of header fields named to the 845.Ar ignored list . 846Header fields in the ignore list are not printed 847on your terminal when you print a message. 848This command is very handy for suppression of certain machine-generated 849header fields. 850The 851.Ic Type 852and 853.Ic Print 854commands can be used to print a message in its entirety, including 855ignored fields. 856If 857.Ic ignore 858is executed with no arguments, it lists the current set of 859ignored fields. 860.It Ic inc 861Incorporate any new messages that have arrived while mail 862is being read. 863The new messages are added to the end of the message list, 864and the current message is reset to be the first new mail message. 865This does not renumber the existing message list, nor does 866it cause any changes made so far to be saved. 867.It Ic invtags 868Invert the tags on a list of messages or the current message if none 869are given. 870Note: this will not affect any currently deleted messages. 871.It Ic mail 872.Pq Ic m 873Takes as argument login names and distribution group names and sends 874mail to those people. 875.It Ic mbox 876Indicate that a list of messages be sent to 877.Ic mbox 878in your home directory when you quit. 879This is the default action for messages if you do 880.Em not 881have the 882.Ic hold 883option set. 884.It Ic mkread 885.Pq Ic mk 886Takes a message list and marks each message as 887having been read. 888.It Ic more 889.Pq Ic \&mo 890Takes a message list and invokes the pager on that list. 891.It Ic next 892.Pf ( Ic n , 893like 894.Ic \&+ 895or 896.Tn CR ) 897Goes to the next message in sequence and types it. 898With an argument list, types the next matching message. 899.It Ic page 900.Pq Ic pa 901A synonym for 902.Ic more . 903.It Ic preserve 904.Pq Ic pre 905A synonym for 906.Ic hold . 907.It Ic print 908.Pq Ic p 909Takes a message list and types out each message on the user's terminal. 910.It Ic quit 911.Pq Ic q 912Terminates the session, saving all undeleted, unsaved messages in 913the user's 914.Ar mbox 915file in his login directory, preserving all messages marked with 916.Ic hold 917or 918.Ic preserve 919or never referenced in his system mailbox, and removing all other 920messages from his system mailbox. 921If new mail has arrived during the session, the message 922.Dq Li "You have new mail" 923is given. 924If given while editing a mailbox file with the 925.Fl f 926flag, then the edit file is rewritten. 927A return to the Shell is effected, unless the rewrite of edit file 928fails, in which case the user can escape with the 929.Ic exit 930command. 931.It Ic reply 932.Pq Ic r 933Takes a message list and sends mail to the sender and all 934recipients of the specified message. 935The default message must not be deleted. 936(See the 937.Ic Reply 938command and the 939.Ar Replyall 940variable.) 941.It Ic respond 942A synonym for 943.Ic reply . 944.It Ic retain 945Add the list of header fields named to the 946.Ar retained list . 947Only the header fields in the retained list 948are shown on your terminal when you print a message. 949All other header fields are suppressed. 950The 951.Ic Type 952and 953.Ic Print 954commands can be used to print a message in its entirety. 955If 956.Ic retain 957is executed with no arguments, it lists the current set of 958retained fields. 959.Ic Retain 960overrides 961.Ic save . 962.It Ic reverse 963Reverse the order of the messages in at the current thread level. 964This is completely equivalent to 965.Dq Li sort \&! . 966.It Ic save 967.Pq Ic s 968Takes a message list and a filename and appends each message in 969turn to the end of the file. 970The filename in quotes, followed by the line 971count and character count is echoed on the user's terminal. 972.It Ic set 973.Pq Ic se 974With no arguments, prints all variable values. 975Otherwise, sets option. 976Arguments are of the form 977.Ar option=value 978(no space before or after =) or 979.Ar option . 980Quotation marks may be placed around any part of the assignment 981statement to quote blanks or tabs, i.e. 982.Dq Li "set indentprefix=\*q->\*q" 983Inside single quotes everything is parsed literally, including 984.Sq \e 985escaped characters. 986Inside double quotes 987.Sq \e 988character escapes are interpreted. 989This is an extension as POSIX specifies that 990.Sq \e 991should be left uninterpreted for both single and double quoted strings. 992.It Ic saveignore 993.Ic Saveignore 994is to 995.Ic save 996what 997.Ic ignore 998is to 999.Ic print 1000and 1001.Ic type . 1002Header fields thus marked are filtered out when 1003saving a message by 1004.Ic save 1005or when automatically saving to 1006.Ar mbox . 1007.\" .pl +1 1008.It Ic saveretain 1009.Ic Saveretain 1010is to 1011.Ic save 1012what 1013.Ic retain 1014is to 1015.Ic print 1016and 1017.Ic type . 1018Header fields thus marked are the only ones saved 1019with a message when saving by 1020.Ic save 1021or when automatically saving to 1022.Ar mbox . 1023.Ic Saveretain 1024overrides 1025.Ic saveignore . 1026.It Ic shell 1027.Pq Ic sh 1028Invokes an interactive version of the shell. 1029.It Ic show 1030.Pq Ic sho 1031Takes a list of variables and prints out their values in the form 1032.Ar option=value . 1033If the list is empty, all variable values are shown. 1034.It Ic showtags 1035Display all current messages, tagged or not, unless they are in a 1036hidden thread. 1037.It Ic showthreads 1038The same as 1039.Ar expose . 1040.It Ic size 1041Takes a message list and prints out the size in characters of each 1042message. 1043.It Ic smopts 1044Takes an 1045.Dq address-spec 1046followed by the sendmail flags that should be used when sending mail 1047to an address that matches that 1048.Dq address-spec . 1049If no sendmail flags are specified, then list the sendmail flags in 1050effect for the 1051.Dq address-spec . 1052If the 1053.Dq address-spec 1054is also omitted, then list all 1055.Ic smopts 1056settings. 1057The 1058.Dq address-spec 1059may be an alias, address, domain (beginning with a 1060.Ql \&@ ) , 1061or subdomain 1062(beginning with a 1063.Ql \&. ) . 1064If mail is sent to multiple users, the sendmail flags are 1065used only if the flags are the same for each recipients. 1066If 1067.Ar smopts-verify 1068is set, then you will be asked to verify the sendmail flags (if there 1069are any) before the mail is sent. 1070Address matching is case insensitive and done from most specific to 1071least. 1072.Pp 1073For example if 1074you have: 1075.Bd -literal -offset indent 1076smopts mylist -F "List Maintainer" 1077smopts @NetBSD.org -f anon@somewhere.net -F "Anon Ymous" 1078smopts friend@NetBSD.org "" 1079.Ed 1080.Pp 1081then mail sent to any of the addresses that the 1082.Ql mylist 1083alias expands to would have the sender's name set to 1084.Ql List Maintainer . 1085Mail sent to anyone at NetBSD.org other than 1086.Ql friend@NetBSD.org 1087would look like it was sent from 1088.Ql anon@somewhere.net 1089by 1090.Ql Anon Ymous . 1091Mail sent to 1092.Ql friend@NetBSD.org 1093would not have any sendmail flags set (unless they are set by the 1094.Ic \&~h 1095escape). 1096.It Ic sort 1097With no argument, 1098.Ic sort 1099does nothing. 1100Otherwise it will sort based on the header field name given as an 1101argument. 1102A few names are special: 1103.Bd -literal -offset indent 1104blines sort based on the number of body lines. 1105hlines sort on the number of header lines. 1106tlines sort on the total number of lines. 1107size sort on the message size 1108sday sent day (ignores the hour/min/sec) 1109rday received day (ignores the hour/min/sec) 1110sdate sent date 1111rdate received date 1112subject sort on the subject, ignoring "Re:" prefixes. 1113from sort on the sender's address. 1114.Ed 1115.Pp 1116The check for these special names is case sensitive while the header 1117field name comparisons are case insensitive, so changing the case on 1118any of these special names will sort based on the header field 1119ignoring the special keyword. 1120.Pp 1121There are also three modifiers which may precede the argument: 1122.Bd -literal -offset indent 1123\&! reverse the sorting order. 1124\&^ case insensitive sorting. 1125\&- skin the field (removing RFC 822 comments and 1126 keep the address). 1127.Ed 1128.Pp 1129The same keywords and modifiers also apply to threading. 1130(See the 1131.Ic thread 1132command.) 1133.Pp 1134Note: 1135.Ic sort 1136has no effect on the threading, sorting only on the heads 1137of the threads if threads exist. 1138.It Ic source 1139The 1140.Ic source 1141command reads commands from a file. 1142.It Ic tag 1143Tag a list of messages or the current message if none are given. 1144In hidden thread mode, the entire thread will be tagged, i.e., 1145.Ic tag 1146is recursive 1147.It Ic tagbelow 1148Tag all messages of the current thread below the level of the 1149current message (dot) or the supplied message number if given. 1150.It Ic thread 1151By default this threads the current message list based on the 1152.Ql In-Reply-To 1153and 1154.Ql References 1155header fields (intended for this purpose by RFC 2822). 1156If given an argument, it will thread on that header field name 1157instead. 1158The same field keywords and modifiers recognized by the sort command 1159are also recognized here. 1160Display of the threads is controlled by the 1161.Ic hide 1162and 1163.Ic expose 1164commands; navigation of threads is done with the 1165.Ic down , 1166.Ic up , 1167and 1168.Ic tset 1169commands. 1170.Pp 1171If 1172.Ar recursive-commands 1173is defined, many commands (e.g., 1174.Ic print ) 1175act on the entire thread (when it is hidden), otherwise they act on 1176just the current message. 1177.Pp 1178Note: the 1179.Ql In-Reply-To 1180and 1181.Ql Reference 1182header fields are necessary to do threading correctly. 1183This version of 1184.Nm 1185now emits these header fields when replying. 1186.It Ic top 1187Takes a message list and prints the top few lines of each. 1188The number of lines printed is controlled by the variable 1189.Ic toplines 1190and defaults to five. 1191.It Ic tset 1192Set the current thread (thread set) so that the supplied message 1193number (or the current message if no argument is given) is at the top 1194level of the current thread. 1195.It Ic type 1196.Pq Ic t 1197A synonym for 1198.Ic print . 1199.It Ic unalias 1200Takes a list of names defined by 1201.Ic alias 1202commands and discards the remembered groups of users. 1203The group names no longer have any significance. 1204.It Ic undelete 1205.Pq Ic u 1206Takes a message list and marks each message as 1207.Ic not 1208being deleted. 1209.It Ic unread 1210.Pq Ic unr 1211Takes a message list and marks each message as 1212.Em not 1213having been read. 1214.It Ic unset 1215Takes a list of option names and discards their remembered values; 1216the inverse of 1217.Ic set . 1218.It Ic unsmopts 1219Takes a list of 1220.Dq address-specs 1221defined by 1222.Ic smopts 1223commands and discards them from the smopts database. 1224.It Ic untag 1225Untag a list of messages or the current message if none are given. 1226Like the 1227.Ic tag 1228command, 1229.Ic untag 1230is recursive on hidden threads. 1231.It Ic unthread 1232Undo all threading and sorting, restoring the original display order, 1233i.e., the order in the mail file. 1234.It Ic up 1235Go up one level in the thread. 1236This also takes an optional (positive) argument to go up multiple 1237levels in the thread. 1238.It Ic view 1239.Pq Ic vie 1240Like 1241.Ic print 1242but has the opposite MIME decoding behavior. 1243(See the 1244.Ar mime-decode-message 1245variable.) 1246.It Ic visual 1247.Pq Ic v 1248Takes a message list and invokes the display editor on each message. 1249.It Ic write 1250.Pq Ic w 1251Similar to 1252.Ic save , 1253except that 1254.Em only 1255the message body 1256.Em ( without 1257the header) is saved. 1258Extremely useful for such tasks as sending and receiving source 1259program text over the message system. 1260.It Ic xit 1261.Pq Ic x 1262A synonym for 1263.Ic exit . 1264.It Ic z 1265.Nm 1266presents message headers in windowfuls as described under the 1267.Ic headers 1268command. 1269You can move 1270.Nm Ns Ap s 1271attention forward to the next window with the 1272.Ic \&z 1273command. 1274Also, you can move to the previous window by using 1275.Ic \&z\&\- . 1276.El 1277.Ss Tilde/Escapes 1278Here is a summary of the tilde escapes, which are used when composing 1279messages to perform special functions. 1280Tilde escapes are only recognized at the beginning of lines. 1281The name 1282.Dq Em tilde\ escape 1283is somewhat of a misnomer since the actual escape character can be set 1284by the option 1285.Ic escape . 1286.Bl -tag -width Ds 1287.It Ic \&~! Ns Ar command 1288Execute the indicated shell command, then return to the message. 1289.It Ic \&~@ Op Ar filelist 1290Add the files in the white-space delimited 1291.Ar filelist 1292to the attachment list. 1293If 1294.Ar filelist 1295is omitted, edit the attachment list, possibly appending to it: For 1296each file in the list the user is prompted to change its attachment 1297data. 1298Changing the filename to empty will delete it from the list. 1299Upon reaching the end of the attachment list, the user is prompted for 1300additional files to attach until an empty filename is given. 1301Filenames containing white-space can only be added in this 1302.Dq edit 1303mode. 1304.It Ic \&~a 1305Inserts the autograph string from the sign= option into the message. 1306.It Ic \&~A 1307Inserts the autograph string from the Sign= option into the message. 1308.It Ic \&~b Ns Ar name ... 1309Add the given names to the list of carbon copy recipients but do not make 1310the names visible in the Cc: line 1311.Dq ( blind 1312carbon copy). 1313.It Ic \&~c Ns Ar name ... 1314Add the given names to the list of carbon copy recipients. 1315.It Ic \&~d 1316Read the file 1317.Dq Pa dead.letter 1318from your home directory into the message. 1319.It Ic \&~e 1320Invoke the text editor on the message collected so far. 1321After the editing session is finished, you may continue appending 1322text to the message. 1323.It Ic \&~f Ns Ar messages 1324Read the named messages into the message being sent. 1325If no messages are specified, read in the current message. 1326Message headers currently being ignored (by the 1327.Ic ignore 1328or 1329.Ic retain 1330command) are not included. 1331.It Ic \&~F Ns Ar messages 1332Identical to 1333.Ic \&~f , 1334except all message headers are included. 1335.It Ic \&~h 1336Edit the message header fields, and the options passed to sendmail (the 1337.Li Smopts ) , 1338by typing each one in turn and allowing the user to append text to the 1339end or modify the field by using the current terminal erase and kill 1340characters. 1341If 1342.Xr editline 3 1343support is included, then that line editor is used. 1344.It Ic \&~i Ns Ar string 1345Inserts the value of the named option into the text of the message. 1346.It Ic \&~m Ns Ar messages 1347Read the named messages into the message being sent, indented by a 1348tab or by the value of 1349.Ar indentprefix . 1350If no messages are specified, read the current message. 1351Message headers currently being ignored (by the 1352.Ic ignore 1353or 1354.Ic retain 1355command) are not included. 1356.It Ic \&~M Ns Ar messages 1357Identical to 1358.Ic \&~m , 1359except all message headers are included. 1360.It Ic \&~p 1361Print out the message collected so far, prefaced by the message header 1362fields. 1363.It Ic \&~q 1364Abort the message being sent, copying the message to 1365.Dq Pa dead.letter 1366in your home directory if 1367.Ic save 1368is set. 1369.It Ic \&~x 1370Exits as with \&~q, except the message is not saved in 1371.Dq Pa dead.letter . 1372.It Ic \&~r Ns Ar filename 1373.It Ic \&~< Ns Ar filename 1374Reads the named file into the message. 1375If the argument begins with 1376.Ql \&! , 1377the rest of the string is taken as an arbitrary system command and is 1378executed, with the standard output inserted into the message. 1379.It Ic \&~s Ns Ar string 1380Cause the named string to become the current subject field. 1381.It Ic \&~\&t Ns Ar name ... 1382Add the given names to the direct recipient list. 1383.It Ic \&~\&v 1384Invoke an alternative editor (defined by the 1385.Ev VISUAL 1386option) on the message collected so far. 1387Usually, the alternative editor will be a screen editor. 1388After you quit the editor, you may resume appending 1389text to the end of your message. 1390.It Ic \&~w Ns Ar filename 1391Write the message onto the named file. 1392.It Ic \&~\&| Ns Ar command 1393Pipe the message body through the command as a filter. 1394If the command gives no output or terminates abnormally, retain the 1395original text of the message. 1396The command 1397.Xr fmt 1 1398is often used as 1399.Ic command 1400to rejustify the message. 1401.It Ic \&~: Ns Ar mail-command 1402Execute the given mail command. 1403Not all commands, however, are allowed. 1404.It Ic \&~~ Ns Ar string 1405Insert the string of text in the message prefaced by a single ~. 1406If you have changed the escape character, then you should double 1407that character in order to send it. 1408.El 1409.Ss Mail Options 1410Options are controlled via 1411.Ic set 1412and 1413.Ic unset 1414commands. 1415Options may be either binary, in which case it is only 1416significant to see whether they are set or not; or string, in which 1417case the actual value is of interest. 1418The binary options include the following: 1419.Bl -tag -width append 1420.It Ar append 1421Causes messages saved in 1422.Ar mbox 1423to be appended to the end rather than prepended. 1424This should always be set (perhaps in 1425.Pa /etc/mail.rc ) . 1426.It Ar ask , Ar asksub 1427Causes 1428.Nm 1429to prompt you for the subject of each message you send. 1430If you respond with simply a newline, no subject field will be sent. 1431.It Ar askcc 1432Causes you to be prompted for additional carbon copy recipients at 1433the end of each message. 1434Responding with a newline indicates your 1435satisfaction with the current list. 1436.It Ar autoinc 1437Causes new mail to be automatically incorporated when it arrives. 1438Setting this is similar to issuing the 1439.Ic inc 1440command at each prompt, except that the current message is not 1441reset when new mail arrives. 1442.It Ar askbcc 1443Causes you to be prompted for additional blind carbon copy recipients 1444at the end of each message. 1445Responding with a newline indicates your 1446satisfaction with the current list. 1447.It Ar autoprint 1448Causes the 1449.Ic delete 1450command to behave like 1451.Ic dp 1452\- thus, after deleting a message, the next one will be typed 1453automatically. 1454.It Va crt 1455If 1456.Va crt 1457is set, then the 1458.Ev PAGER 1459will be used for the 1460.Ic print , 1461.Ic Print , 1462.Ic type , 1463and 1464.Ic Type 1465commands. 1466Normally these commands do not invoke the pager. 1467(See 1468.Va page-also . ) 1469.It Ar debug 1470Setting the binary option 1471.Ar debug 1472is the same as specifying 1473.Fl d 1474on the command line and causes 1475.Nm 1476to output all sorts of information useful for debugging 1477.Nm . 1478.It Ar dot 1479The binary option 1480.Ar dot 1481causes 1482.Nm 1483to interpret a period alone on a line as the terminator 1484of a message you are sending. 1485.It Ar enable-pipes 1486If defined, the output of most commands can be piped into a shell 1487command or redirected to a file. 1488The pipe/redirection is signaled by the first occurrence of a 1489.Ql \&| 1490or 1491.Ql > 1492character that is not in a quoted string or in a parenthetical 1493group. 1494This character terminates the mail command line and the remaining 1495string is passed to the shell. 1496For example, assuming normal headers, something like 1497.Bd -literal -offset indent 1498 from john@ | fgrep -i ' "Re:' | wc 1499.Ed 1500.Pp 1501could be used to count how many replies were made by senders with 1502.Ql john@ 1503in their address and 1504.Bd -literal -offset indent 1505 from john@ >> /tmp/john 1506.Ed 1507.Pp 1508would append all the headers from such senders to /tmp/john. 1509.Pp 1510Note: With piping enabled, you cannot use the 1511.Ql \&| 1512as a logical 1513.Dq or 1514operator outside of a parenthetical group. 1515This should not be a problem as it is the default logical operator. 1516(See the 1517.Sx Specifying messages 1518section.) 1519.It Ar hold 1520This option is used to hold messages in the system mailbox 1521by default. 1522.It Ar ignore 1523Causes interrupt signals from your terminal to be ignored and echoed as 1524@'s. 1525.It Ar metoo 1526Usually, when a group is expanded that contains the sender, the sender 1527is removed from the expansion. 1528Setting this option causes the sender to be included in the group. 1529.It Ar mime-attach-list 1530If set, the command line flag 1531.Fl a 1532will accept a whitespace delimited list of files. 1533Otherwise, its argument is interpreted as a single filename. 1534Warning: If enabled, care must be taken to properly quote files that 1535contain whitespace, both from the shell and from this second expansion 1536done by 1537.Nm . 1538.It Ar mime-decode-header 1539If set, decode the headers along with the body when 1540.Ar mime-decode-message 1541is set. 1542The header decode follows the same rules as the body (see 1543.Ar mime-decode-message ) . 1544.It Ar mime-decode-insert 1545When inserting 1546a message into the mail buffer 1547.Po Ic \&~f 1548or 1549.Ic \&~F 1550.Pc , 1551the text inserted will be decoded according to the settings of the 1552.Ar mime-decode-message 1553and 1554.Ar mime-decode-header 1555variables. 1556.It Ar mime-decode-message 1557If set, the 1558.Ic More , 1559.Ic more , 1560.Ic Page , 1561.Ic page , 1562.Ic Print , 1563.Ic print , 1564.Ic Type , 1565and 1566.Ic type 1567commands will display decoded the MIME messages. 1568Otherwise, they display the undecoded message. 1569Recall that the 1570.Ic View 1571and 1572.Ic view 1573commands always have the opposite MIME decoding behavior from these 1574commands. 1575.It Ar mime-decode-quote 1576When quoting 1577a message into the mail buffer 1578.Po Ic \&~m 1579or 1580.Ic \&~M 1581.Pc , 1582the text inserted will be decoded according to the settings of the 1583.Ar mime-decode-message 1584and 1585.Ar mime-decode-header 1586variables. 1587.It Ar mime-detach-batch 1588If set, the detach command does not prompt for anything 1589.Po unless 1590.Ar mime-detach-overwrite 1591is set to 1592.Ql ask 1593.Pc , 1594overwriting target files depending on the setting of 1595.Ar mime-detach-overwrite . 1596.It Ar noheader 1597Setting the option 1598.Ar noheader 1599is the same as giving the 1600.Fl N 1601flag on the command line. 1602.It Ar nosave 1603Normally, when you abort a message with two 1604.Tn RUBOUT 1605(erase or delete) 1606.Nm 1607copies the partial letter to the file 1608.Dq Pa dead.letter 1609in your home directory. 1610Setting the binary option 1611.Ar nosave 1612prevents this. 1613.It Ar page-also 1614A comma or whitespace delimited list of additional commands to page. 1615The comparisons are case insensitive, so if 1616.Ic view 1617is in the list, both 1618.Ic view 1619and 1620.Ic View 1621will page. 1622.It Ar pager-off 1623If set, disable the pager on all commands. 1624.It Ar quiet 1625Suppresses the printing of the version when first invoked. 1626.It Ar recursive-commands 1627When defined, and threading is in effect, the following commands 1628operate on the entire thread (if it is 1629.Dq hidden ) 1630rather than just the top displayed message of the thread: 1631.Bd -literal -offset indent 1632More Page Print Type View more page print type view 1633top 1634Save copy save write 1635Detach detach 1636delete dp dt 1637undelete 1638hold preserve 1639mbox mkread touch unread 1640tag untag invtags 1641.Ed 1642.Pp 1643If not defined, or if the threads are 1644.Dq exposed , 1645commands behave exactly as they do in non-threaded mode, i.e., each 1646operates on individual messages. 1647.It Ar Replyall 1648Reverses the sense of 1649.Ic reply 1650and 1651.Ic Reply 1652commands. 1653.It Ar searchheaders 1654If this option is set, then a message-list specifier in the form 1655.Dq /x:y 1656will expand to all messages containing the substring 1657.Dq y 1658in the header field 1659.Dq x . 1660The string search is case insensitive. 1661If 1662.Dq x 1663is omitted, it will default to the 1664.Ql Subject 1665header field. 1666If 1667.Dq y 1668is omitted, only those messages that contain the field 1669.Dq x 1670will be matched. 1671The three forms 1672.Dq /from:y , 1673.Dq /to:y , 1674and 1675.Dq /body:y 1676are special. 1677The first will match all messages which contain the substring 1678.Dq y 1679in the headline (which is added locally at receipt time and begins 1680with 1681.Dq From \& ) . 1682The second will match all messages containing the substring 1683.Dq y 1684in the 1685.Ql To , 1686.Ql Cc , 1687or 1688.Ql Bcc 1689header fields. 1690The third will match all messages which contain the substring 1691.Dq y 1692in a line of the message body. 1693The check for 1694.Dq from , 1695.Dq to , 1696and 1697.Dq body 1698is case sensitive, so that 1699.Dq /From:y 1700and 1701.Dq /To:y 1702can be used to search the 1703.Ql From 1704and 1705.Ql To 1706fields, respectively. 1707(See also 1708.Ar "regex-search" . ) 1709.It Ar smopts-verify 1710Verify the sendmail options used on outgoing mail if they were obtained from a 1711.Ar smopts 1712match. 1713This has no effect if there are no sendmail flags or if the flags 1714were set by the 1715.Ic \&~h 1716escape. 1717.It Ar verbose 1718Setting the option 1719.Ar verbose 1720is the same as using the 1721.Fl v 1722flag on the command line. 1723When mail runs in verbose mode, the actual delivery of messages is 1724displayed on the user's terminal. 1725.El 1726.Ss Option String Values 1727.Bl -tag -width Va 1728.It Ev EDITOR 1729Pathname of the text editor to use in the 1730.Ic edit 1731command and 1732.Ic \&~e 1733escape. 1734If not defined, then a default editor is used. 1735.It Ev LISTER 1736Pathname of the directory lister to use in the 1737.Ic folders 1738command. 1739Default is 1740.Pa /bin/ls . 1741.It Ev PAGER 1742Pathname of the program to use in the 1743.Ic more 1744command or when 1745.Ic crt 1746variable is set. 1747The default paginator 1748.Xr more 1 1749is used if this option is not defined. 1750.It Ev SHELL 1751Pathname of the shell to use in the 1752.Ic \&! 1753command and the 1754.Ic \&~! 1755escape. 1756A default shell is used if this option is not defined. 1757.It Ev VISUAL 1758Pathname of the text editor to use in the 1759.Ic visual 1760command and 1761.Ic \&~v 1762escape. 1763.It Ar el-completion-keys 1764A comma or space delimited list of keys to do 1765.Xr editline 3 1766completion. 1767For example 1768.Nm set el-completion-keys=^I,^D 1769will bind completion to both the tab and CTRL-D keys. 1770(Requires 1771.Xr editline 3 1772support.) 1773.It Ar el-editor 1774The line editing mode: must be 1775.Ql emacs 1776or 1777.Ql vi . 1778If unset, editing is not enabled. 1779(Requires 1780.Xr editline 3 1781support.) 1782.It Ar el-history-size 1783The number of lines of history to remember. 1784If unset, history is not enabled. 1785(Requires 1786.Xr editline 3 1787support.) 1788.It Ar escape 1789If defined, the first character of this option gives the character to 1790use in the place of 1791.Ic \&~ 1792to denote escapes. 1793.It Ar folder 1794The name of the directory to use for storing folders of 1795messages. 1796If this name begins with a 1797.Ql / , 1798.Nm 1799considers it to be an absolute pathname; otherwise, the 1800folder directory is found relative to your home directory. 1801.It Ar header-format 1802If set, use this format string when displaying headers in command 1803mode. 1804The format string supports the following conversions in addition to 1805those of 1806.Xr strftime 3 : 1807.Pp 1808.Bl -tag -width ".Ar \&%?key?" -compact 1809.It Ar \&%?key? 1810The header field with name 1811.Ql key . 1812Note: if key[0] is 1813.Ql \&- , 1814ignore the 1815.Ql \&- 1816and extract the address 1817portion of the field (i.e., 1818.Dq skin 1819the field). 1820.It Ar \&%?*string? 1821If the depth is 1822.Ar n , 1823substitute 1824.Ql string 1825.Ar n 1826times. 1827This is intended to be used when displaying an 1828.Dq exposed thread . 1829.It Ar \&%?&string? 1830Like 1831.Ar \&%?*string? , 1832but uses the depth relative to the current depth rather than the 1833absolute depth. 1834.It Ar \&%J 1835The number of header lines in the message. 1836.It Ar \&%K 1837The number of body lines in the message. 1838.It Ar \&%L 1839The total number of lines in the message. 1840.It Ar \&%N 1841The sender's full name (as in the 1842.Ql From 1843or 1844.Ql Sender 1845fields). 1846.It Ar \&%O 1847The message size. 1848.It Ar \&%P 1849The current 1850.Dq dot 1851.Pq Sq > 1852message. 1853.It Ar \&%Q 1854The message status flag. 1855.It Ar \&%Z 1856The time zone name (if it exists). 1857.It Ar \&%f 1858The email address of sender. 1859.It Ar \&%i 1860The message number. 1861.It Ar \&%n 1862The sender's login name (taken from the address). 1863.It Ar \&%q 1864The subject. 1865.It Ar \&%t 1866The total number of messages. 1867.It Ar \&%z 1868The GMT offset (if found). 1869.El 1870.Pp 1871If the format string begins with 1872.Ql "\&%??" 1873then the date will be extracted from the headline. 1874Otherwise it will be extracted from the 1875.Ql Date 1876header falling back to the headline if that extraction fails. 1877For example, the default format is: 1878.Bd -literal -offset 0 1879set header-format=\&"\&%??%P%Q%?* ?%3i \&%-21.20f \&%a \&%b \&%e \&%R \&%3K/%-5O \&\e"%q\e"" 1880.Ed 1881.Pp 1882Note 1: The message status flag 1883.Ql \&%Q 1884will display the single character 1885.Ql \&+ 1886for the parent of a subthread. 1887This will be overwritten by a 1888.Ql T , 1889.Ql E , 1890.Ql \&* , 1891.Ql P , 1892.Ql U , 1893.Ql N , 1894.Ql M 1895indicating, respectively, a tagged, modified, saved, preserved, 1896unread, new, or modified message, in that order with the last matching 1897condition being the one displayed. 1898In the case of hidden threads, the entire subthread is searched and 1899the letters above will be displayed in lower case if the property is 1900that of a hidden child with the case 1901.Ql \&* 1902being displayed as 1903.Ql & . 1904.Pp 1905Note 2: 1906.Ar \&%n 1907and 1908.Ar \&%t 1909as used by 1910.Xr strftime 3 1911were redundant with \et and \en, respectively, so nothing is lost 1912using them here. 1913.It Ar ignoreeof 1914An option related to 1915.Ar dot 1916is 1917.Ar ignoreeof 1918which makes 1919.Nm 1920refuse to accept a 1921.Ql control-D 1922as the end of a message. 1923If given a numeric argument 1924.Ar n , 1925a 1926.Ql control-D 1927will be accepted after 1928.Ar n 1929tries. 1930.Ar Ignoreeof 1931also applies to 1932.Nm 1933command mode. 1934.It Ar indentpreamble 1935If set, this format string will be inserted before quoting a message 1936.Po Ic \&~m 1937or 1938.Ic \&~M 1939.Pc . 1940The format syntax is the same as for 1941.Ar header-format . 1942For example, the following: 1943.Bd -literal -offset 0 1944set indentpreamble= 1945 \&"On \&%b \&%e \&%T, \&%Y \&%z (%Z), \&%n (%.50N) wrote:\en-- Subject: \&%.65q\en" 1946.Ed 1947.Pp 1948would insert something like 1949.Bd -literal -offset 0 1950On Oct 27 11:00:07, 2006 -0400 (EDT), anon (Anon Ymous) wrote: 1951-- Subject: suggestions for mail(1) 1952.Ed 1953.Pp 1954before the quoted message. 1955.It Ar indentprefix 1956String used by the 1957.Ic ~m 1958and 1959.Ic ~M 1960tilde escapes for indenting messages, in place of 1961the normal tab character 1962.Pq Sq ^I . 1963Be sure to quote the value if it contains 1964spaces or tabs. 1965.It Ar indentpostscript 1966If set, this format string will be inserted after quoting a message 1967.Po Ic \&~m 1968or 1969.Ic \&~M 1970.Pc . 1971The format syntax is the same as for 1972.Ar header-format . 1973For example, the following: 1974.Bd -literal -offset 0 1975set indentpostscript="-- End of excerpt from \&%.50N" 1976.Ed 1977.Pp 1978would insert something like 1979.Bd -literal -offset 0 1980-- End of excerpt from Anon Ymous 1981.Ed 1982.Pp 1983after the quoted message. 1984.It Ar mime-body-TYPE-SUBTYPE 1985MIME-hook for the body of a MIME block of 1986.Ql "Content-Type: TYPE/SUBTYPE" . 1987(See 1988.Sy MIME Enhancements 1989below.) 1990.It Ar mime-charset 1991Convert 1992.Ql "Content-type: text" 1993messages to this character set or 1994.Ql us-ascii 1995if the value is empty. 1996If unset, no character set conversion is done. 1997.It Ar mime-detach-dir 1998The directory to detach files to if the 1999.Ar detach 2000command is given no arguments. 2001(See 2002.Ar detach . ) 2003.It Ar mime-detach-overwrite 2004This controls overwriting of existing files by the detach command. 2005If set to 2006.Ql ask 2007the user will be prompted before overwriting a file. 2008If set to 2009.Ql yes , 2010or to the empty string, existing target files will be overwritten. 2011If set to 2012.Ql no , 2013no target files will be overwritten. 2014.It Ar mime-encode-message 2015If set, encode the body of the message as required. 2016Typically, this is just an issue of whether 2017.Ql quoted-printable 2018encoding is used or not. 2019If it has a value, then use it to determine the encoding type. 2020Allowed values are 2021.Ql 7bit , 2022.Ql 8bit , 2023.Ql binary , 2024.Ql quoted-printable , 2025or 2026.Ql base64 . 2027.It Ar mime-head-TYPE-SUBTYPE 2028MIME-hook for the header of a MIME block of 2029.Ql "Content-Type: TYPE/SUBTYPE" . 2030(See 2031.Sy MIME Enhancements 2032below.) 2033.It Ar mime-hook-TYPE-SUBTYPE 2034MIME-hook for MIME block of 2035.Ql "Content-Type: TYPE/SUBTYPE" . 2036(See 2037.Sy MIME Enhancements 2038below.) 2039.It Ev MBOX 2040The name of the 2041.Ar mbox 2042file. 2043It can be the name of a folder. 2044The default is 2045.Dq Li mbox 2046in the user's home directory. 2047.It Ar prompt 2048If defined, it specifies the prompt to use when in command mode. 2049Otherwise, the default 2050.Ql & 2051is used. 2052The format syntax is the same as for 2053.Ar header-format . 2054.It Ar record 2055If defined, gives the pathname of the file used to record all outgoing 2056mail. 2057If not defined, then outgoing mail is not so saved. 2058.It Ar regex-search 2059If set, regular expression searches are used, instead of simple case 2060insensitive substring matches, when determining message lists by 2061searching sender names, subjects, or header fields (if 2062.Ar searchheaders 2063is defined); see the 2064.Sx Specifying messages 2065section. 2066The value of the variable is a space or comma delimited list of 2067options. 2068Valid options are 2069.Ql icase 2070to do case insensitive searches, 2071.Ql extended 2072to use extended (rather than basic) regular expressions, and 2073.Ql nospec 2074to turn off all special character meanings and do literal string 2075searches. 2076Note that 2077.Ql extended 2078and 2079.Ql nospec 2080are not compatible (see 2081.Xr regcomp 3 ) . 2082.It Ar ReplyAsRecipient 2083This is used when replying to email (see the 2084.Ic reply 2085or 2086.Ic Reply 2087commands). 2088It is useful if you have multiple email addresses and wish to ensure 2089that replies respect them. 2090If set, grab the email address(es) from the 2091.Ql To 2092field of the message being replied to. 2093If there is only one such address, and if it does not match any 2094address in the value of 2095.Ar ReplyAsRecipient 2096(a comma or space delimited list of addresses, possibly empty), then 2097use this address in the 2098.Ql From 2099field of the reply. 2100This is accomplished by passing the address to 2101.Xr sendmail 1 2102with the 2103.Fl f 2104option. 2105Note: the sendmail options can be edited with the 2106.Ic \&~h 2107escape. 2108(See also the 2109.Ic smopts 2110command.) 2111.It Ar toplines 2112If defined, gives the number of lines of a message to be printed out 2113with the 2114.Ic top 2115command; normally, the first five lines are printed. 2116.El 2117.Ss MIME Enhancements 2118A MIME message is (recursively) divided into a series of MIME parts 2119that can be thought of as sub-messages, each with a header and body. 2120When MIME support is enabled (by setting 2121.Ar mime-decode-message ) , 2122.Nm 2123splits a message into a series of its smallest MIME parts and 2124processes those parts as if they were messages themselves, passing the 2125header and body through a pipeline of the form: 2126.Pp 2127.Dl mail -> MIME-decoder -> MIME-hook -> pager -> screen 2128.Pp 2129The 2130.Em MIME-decoder 2131decodes 2132.Ql base64 2133or 2134.Ql quoted-printable 2135encoding and is enabled according to the 2136.Ql Content-Transfer-Encoding 2137of the part. 2138The 2139.Em MIME-hook 2140is an external program to further process the part (see below). 2141The 2142.Em pager 2143is the program that pages the message 2144(see 2145.Ev PAGER ) . 2146Any of these intermediate pipe stages may be missing and/or different 2147for the head and body of each MIME part. 2148Certain 2149.Ql Content-Types 2150may disable the entire pipeline (e.g., 2151.Ql application/octet ) . 2152.Pp 2153The 2154.Em MIME-hook 2155stage is not present unless one of the following variables is set: 2156.Bd -literal -offset indent 2157mime-hook-TYPE-SUBTYPE applies to the entire MIME part 2158mime-head-TYPE-SUBTYPE applies to the header of the MIME part 2159mime-body-TYPE-SUBTYPE applies to the body of the MIME part 2160.Ed 2161.Pp 2162where TYPE and SUBTYPE are the 2163.Ql Content-Type 2164type and subtype 2165(respectively) of the MIME part to which the hook applies. 2166If the 2167.Dq -SUBTYPE 2168is missing, any subtype is matched. 2169The value of these variables has the format: 2170.Bd -filled -offset indent 2171.Op Ar flags 2172.Ar command 2173.Ed 2174.Pp 2175where the 2176.Ar command 2177is expected to read from stdin and write to stdout, and the possible 2178flags are 2179.Bl -tag -width Ds -offset indent 2180.It ! 2181Execute 2182.Ar command 2183in a sub-shell rather than doing an 2184.Xr exec 3 2185(see 2186.Va SHELL ) . 2187.It + 2188Use this hook when selecting the part to display in a 2189.Ql multipart/alternative 2190block. 2191Multipart blocks contain 2192.Dq alternative 2193versions with the same information, in increasing order of preference 2194(and decoding complexity). 2195The last one the mail agent understands is the one to be displayed. 2196This is typically used for sending a message in both 2197.Dq plain text 2198and 2199.Dq html , 2200but more complex subtypes are also possible. 2201.It - 2202Do not decode before executing 2203.Ar command . 2204.El 2205.Pp 2206If your 2207.Ar command 2208begins with one of these flags, precede it with a space to signal the 2209end of the flags. 2210.Pp 2211WARNING: automatically running a program is a potential security risk 2212if that program has bugs, so be careful what you run. 2213.Pp 2214.Em Examples : 2215View all 2216.Ql "Content-Type: image/jpeg" 2217parts with 2218.Xr xv 1 2219(assuming it is installed): 2220.Pp 2221.Dl set mime-body-image-jpeg="/usr/pkg/bin/xv -" 2222.Pp 2223Decode all 2224.Ql "Content-Type: images/*" 2225blocks with 2226.Xr uudeview 1 2227(assuming it is installed), placing the results in 2228.Pa /tmp : 2229.Pp 2230.Dl set mime-hook-image="-/usr/pkg/bin/uudeview -p /tmp -i -a +o -q -" 2231.Pp 2232Read all 2233.Ql "Content-Type: text/html" 2234parts using 2235.Xr lynx 1 2236(assuming it is installed) and add this support to 2237.Ql multipart/alternative 2238blocks: 2239.Bd -literal -offset indent 2240set mime-body-text-html="+/usr/pkg/bin/lynx -force_html -dump -stdin" 2241.Ed 2242.Sh ENVIRONMENT 2243.Nm 2244uses the 2245.Ev HOME , 2246.Ev TMPDIR , 2247and 2248.Ev USER 2249environment variables. 2250.Sh FILES 2251.Bl -tag -width /usr/share/misc/mail.*help -compact 2252.It Pa /var/mail/* 2253Post office. 2254This can be overwritten by setting the 2255.Ev MAIL 2256environment variable. 2257.It ~/mbox 2258User's old mail. 2259This can be overwritten by setting the 2260.Ev MBOX 2261environment variable. 2262.It ~/.mailrc 2263File giving initial mail commands. 2264This can be overridden by setting the 2265.Ev MAILRC 2266environment variable. 2267.It Pa /tmp/mail.R* 2268Temporary files. 2269.It Pa /usr/share/misc/mail.*help 2270Help files. 2271.It Pa /etc/mail.rc 2272System initialization file. 2273.El 2274.Sh SEE ALSO 2275.Xr fmt 1 , 2276.Xr newaliases 1 , 2277.Xr sendmail 1 , 2278.Xr vacation 1 , 2279.Xr aliases 5 , 2280.Xr mailaddr 7 2281and 2282.Rs 2283.%T "The Mail Reference Manual" 2284.Re 2285.Sh HISTORY 2286A 2287.Nm 2288command 2289appeared in 2290.At v1 . 2291This man page is derived from 2292.Dq The Mail Reference Manual 2293originally written by Kurt Shoens. 2294.Sh BUGS 2295There are some flags and commands that are not documented here. 2296Most are not useful to the general user. 2297.Pp 2298Historically, 2299.Nm 2300was just a link to 2301.Nm Mail , 2302which was confusing. 2303.Nm Mail 2304has been removed in 2305.Nx 9 . 2306.Pp 2307The name of the 2308.Ic alternates 2309list is incorrect English (it should be 2310.Dq alternatives ) , 2311but is retained for compatibility. 2312.Pp 2313There must be sufficient space on $TMPDIR for various temporary files. 2314.Pp 2315If an unrecoverable character set conversion error occurs (during 2316display), the message is truncated and a warning is printed. 2317This seems to be rare, but probably the remainder of the message 2318should be printed without conversion. 2319.Pp 2320The internal sh-like parser is not terribly sh-like. 2321.Pp 2322Selecting messages by their content (i.e., with 2323.Ql /body: ) 2324is rather slow. 2325