MHMAIL(1mh)
okay bestie, sit down, hydrate, because we're doing MHMAIL(1mh) together and honestly it's giving β¨automationβ¨ in the best way. This page lives in the nmh manual (section 1mh, if you were wondering), and it's all about sending or reading mail with zero interactive nonsense.
πΈ NAME πΈ
mhmail β send or read mail non-interactively with nmh π
π SYNOPSIS π
mhmail [-help] [-version] [-to] addrs ... [-attach file] [-body text]
[-cc addrs ...] [-from addr] [-headerfield name:value] [-subject
subject] [-resent] [switches for post ... | -profile [switches for
send ...]] [-send | -nosend]
and the one you need to memorize: mhmail with no arguments is equivalent to inc. periodt. π
π DESCRIPTION π
mhmail is meant to be a replacement β compatible with nmh β for the standard Berkeley mail program (mail or mailx). nmh is built for programs like cron that just expect to send mail automatically, no human in the loop. It's also used by some nmh commands to mail out error notifications. And yeah, you can use mhmail interactively, but it's recommended that you use comp and send instead when you're sending messages. iykyk π«Ά
When you invoke it with no arguments at all, mhmail simply invokes inc to incorporate new messages from your mail drop. cute, effortless, iconic. π
When one or more addresses are specified, a message gets read from the standard input and spooled to a temporary file. Then mhmail invokes post by default, with the name of that temporary file as its argument, to deliver the message to the address(es) you specified. π«
The -subject switch lets you set the βSubject:β field of the message.
The -resent switch says: hey, this message body is a fully formed message that will be resent, exactly like dist would do. For example:
mhmail u2@example.com -resent <`mhpath cur`
By default, mhmail reads the message to be sent from the standard input. But you can hand it the text of the message right at the command line with the -body text switch. Now listen, this part matters: if the standard input has zero length, mhmail will not send the message and returns with status 1. You can use the switch -body "" to force an empty message. no cap. π
Normally, addresses that appear as arguments get put in the βTo:β field. And you need at least one such address when sending a message β like, if any other switches are supplied. If you use the -cc switch, then all addresses following it go in the βcc:β field β even if there are intervening switches other than -to. The optional -to switch can appear in front of any addresses to signify their placement in the βTo:β field. And both -to and -cc may be given multiple times. slay. β¨
Using -from addr, you can specify the βFrom:β header of the draft. If no -from switch is used when sending, mhmail will supply a βFrom:β header field using the sender's local mailbox β see localmbox in mh-format(5). Naturally, post will fill in the βSender:β header correctly. π
The -headerfield name:value switch adds a header field with the specified name and value to the message. (That value is called the field body in RFC 2822, but that's too easily confused with the message body, so. yeah.) There doesn't need to be a space after the colon that separates the name and value in the argument to this switch. It's usually best to wrap the argument in quotes to protect it from the shell. And -headerfield may be given multiple times to add multiple header fields, for example:
mhmail -from sender@example.com \
-headerfield 'MIME-Version:1.0' \
-headerfield 'Content-Type:text/plain; charset=utf-8' \
-headerfield 'Content-Transfer-Encoding:8bit' \
recipient@example.com
note about this example, bestie: the-attachswitch causesMIME-VersionandContent-Typeheaders to be added to the message. π
The -profile switch instructs mhmail to use send instead of post to send the message. This allows use of the user's context and aliases. π¦
The -attach file switch attaches the specified file to the message. Using -attach enables -profile, because mhmail uses send to handle the attachment. It's usually best to enclose the argument in quotes to protect it from the shell. And -attach may be given multiple times to add multiple attachments. πΈ
The -nosend option shows the draft file that would be posted/sent on the command's standard output, but it does not post or send it. -send provides the default behavior of posting or sending the message. It can be used to disable -nosend, for example when you're using a shell alias. π₯
All other switches are passed to post if -profile is not used, or to send if -profile is used.
π FILES π
/usr/bin/mh/incβ Program to incorporate mail drop into folder/usr/lib/mh/postβ Program to deliver a message/tmp/mhmail*β Temporary copy of message
π§ PROFILE COMPONENTS π§
mhmail does not consult the user's .mh_profile. π (yes really, it's that independent.)
π SEE ALSO π
dist(1), send(1), mh-format(5), send(1), post(8)
β DEFAULTS β
-from localmbox-profileis enabled by default only with-attach-send
π¦ CONTEXT π¦
If inc is invoked, then inc's context changes occur. With the -profile switch, the context of send is used. mhmail does not read the context file itself. β¨
and that's the whole page, bestie β nmh-1.8, dated 2012-07-01. go forth and automate your mail, you absolute main character π ππ
π¦ where this page comes from
- debian trixie: nmh 1.8-3
- ubuntu noble: nmh 1.8-1build4
- ubuntu questing: nmh 1.8-3
- ubuntu resolute: nmh 1.8-4
- ubuntu stonking: nmh 1.8-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms