MHMAIL(1mh)

πŸ“¦
version 1.8 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

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 -attach switch causes MIME-Version and Content-Type headers 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
  • -profile is 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