1MHMAIL(1) General Commands Manual MHMAIL(1)
2
3
4
6 mhmail - send or read mail non-interactively with nmh
7
9 mhmail [-help] [-version] [-to] addrs ... [-attach file] [-body text]
10 [-cc addrs ...] [-from addr] [-headerfield name:value] [-subject
11 subject] [-resent] [switches for post ... | -profile [switches for
12 send ...]] [-send | -nosend]
13
14 mhmail with no arguments is equivalent to inc
15
17 mhmail is intended as a replacement, compatible with nmh, for the stan‐
18 dard Berkeley mail program (mail or mailx). nmh is intended for the
19 use of programs such as cron, which expect to send mail automatically.
20 It is also used by some nmh commands to mail error notifications.
21 Although mhmail can be used interactively, it is recommended that comp
22 and send be used instead, to send messages.
23
24 When invoked without arguments, mhmail simply invokes inc to incorpo‐
25 rate new messages from the user's mail drop.
26
27 When one or more addresses are specified, a message is read from the
28 standard input and spooled to a temporary file. mhmail then invokes by
29 default, with the name of the temporary file as its argument, to by
30 default, with the name of the temporary file as its argument to deliver
31 the message to the specified address.
32
33 The -subject switch can be used to specify the “Subject:” field of the
34 message. “Subject:” field of the message.
35
36 The -resent switch indicates that the message body is a fully formed
37 message that will be resent, as dist would do. For example:
38
39 mhmail u2@example.com -resent < `mhpath cur`
40
41 By default, mhmail will read the message to be sent from the standard
42 input. You can specify the text of the message at the command line
43 with the -body text switch. If the standard input has zero length,
44 mhmail will not send the message and return with status 1. You can use
45 the switch -body “” to force an empty message.
46
47 Normally, addresses appearing as arguments are put in the “To:” field.
48 At least one such address is required when sending a message, i.e., if
49 any other switches are supplied. If the -cc switch is used, all
50 addresses following it, even if there are intervening switches other
51 than -to, are placed in the “cc:” field. The optional -to switch can
52 appear in front of any addresses to signify their placement in the
53 “To:” field. The -to and -cc switches may be given multiple times.
54
55 By using -from addr, you can specify the “From:” header of the draft.
56 If no -from switch is used when sending, mhmail will supply a “From:”
57 header field using the sender's local mailbox, see localmbox in mh-for‐
58 mat(5). Naturally, post will fill in the “Sender:” header correctly.
59
60 The -headerfield name:value switch adds a header field with the speci‐
61 fied name and value to the message. (The value is called the field
62 body in RFC 2822, but that's too easily confused with the message
63 body.) There need not be a space after the colon that separates the
64 name and value in the argument to this switch. It is usually best to
65 enclose the argument in quotes to protect it from the shell. The
66 -headerfield switch may be given multiple times to add multiple header
67 fields, for example,
68
69 mhmail -from sender@example.com \
70 -headerfield 'MIME-Version:1.0' \
71 -headerfield 'Content-Type:text/plain; charset=utf-8' \
72 -headerfield 'Content-Transfer-Encoding:8bit' \
73 recipient@example.com
74
75 Note about this example: the -attach switch causes MIME-Version and
76 Content-Type headers to be added to the message.
77
78 The -profile switch instructs mhmail to use send instead of post to
79 send the message. This allows use of the user's context and aliases.
80
81 The -attach file switch attaches the specified file to the message.
82 Use of -attach enables -profile because mhmail uses send to handle the
83 attachment. It is usually best to enclose the argument in quotes to
84 protect it from the shell. The -attach switch may be given multiple
85 times to add multiple attachments.
86
87 The -nosend option shows the draft file that would be posted/sent on
88 the command's standard output but does not post or send it. -send pro‐
89 vides the default behavior of posting or sending the message. It can
90 be used to disable -nosend, for example, when using a shell alias.
91
92 All other switches are passed to post if -profile is not used, or send
93 if -profile is used.
94
96 /usr/bin/inc Program to incorporate mail drop into folder
97 /usr/libexec/nmh/post Program to deliver a message
98 /tmp/mhmail* Temporary copy of message
99
101 dist(1), send(1), mh-format(5), send(1), post(8)
102
104 `-from localmbox'
105 `-profile' is enabled by default only with -attach
106 `-send'
107
109 If inc is invoked, then inc's context changes occur. With the -profile
110 switch, the context of send is used. mhmail does not read the context
111 file itself, so an entry for it will be ignored.
112
113
114
115nmh-1.7.1 2012-07-01 MHMAIL(1)