# man > mhmail(1mh)

[_MHMAIL_(1mh)](https://www.chedong.com/phpMan.php/man/MHMAIL/1mh/markdown)                                                                              [_MHMAIL_(1mh)](https://www.chedong.com/phpMan.php/man/MHMAIL/1mh/markdown)

## 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**]

       **mhmail **with no arguments is equivalent to **inc**

## DESCRIPTION
       **mhmail **is intended as a replacement, compatible with **nmh**, for the standard Berkeley mail pro‐
       gram  (**mail **or **mailx**).  **nmh **is intended for the use of programs such as **cron**, which expect to
       send mail automatically.  It is also used by some **nmh **commands to mail  error  notifications.
       Although  **mhmail  **can be used interactively, it is recommended that **comp **and **send **be used in‐
       stead, to send messages.

       When invoked without arguments, **mhmail **simply invokes **inc **to incorporate  new  messages  from
       the user's mail drop.

       When  one  or  more  addresses  are  specified, a message is read from the standard input and
       spooled to a temporary file.  **mhmail **then invokes by default, with the name of the  temporary
       file  as  its argument, to by default, with the name of the temporary file as its argument to
       deliver the message to the specified address.

       The **-subject **switch can be used to specify the “Subject:” field of the  message.   “Subject:”
       field of the message.

       The **-resent **switch indicates that the message body is a fully formed message that will be re‐
       sent, as **dist **would do.  For example:

            mhmail <u2@example.com> -resent <`mhpath cur`

       By default, **mhmail **will read the message to be sent from the standard input.  You can specify
       the  text of the message at the command line with the **-body _**text_ switch.  If the standard in‐
       put has zero length, **mhmail **will not send the message and return with status 1.  You can  use
       the switch **-body **“” to force an empty message.

       Normally, addresses appearing as arguments are put in the “To:” field.  At least one such ad‐
       dress  is  required when sending a message, i.e., if any other switches are supplied.  If the
### -cc 
       than  **-to**, are placed in the “cc:” field.  The optional **-to **switch can appear in front of any
       addresses to signify their placement in the “To:” field.  The **-to **and  **-cc  **switches  may  be
       given multiple times.

       By  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  mail‐
       box,  see  _localmbox_ in [_mh-format_(5)](https://www.chedong.com/phpMan.php/man/mh-format/5/markdown).  Naturally, **post **will fill in the “Sender:” header cor‐
       rectly.

       The **-headerfield _**name:value_ switch adds a header field with the specified name and  value  to
       the message.  (The _value_ is called the _field_ _body_ in RFC 2822, but that's too easily confused
       with  the  message  body.)  There need not be a space after the colon that separates the name
       and value in the argument to this switch.  It is usually best  to  enclose  the  argument  in
       quotes  to protect it from the shell.  The **-headerfield **switch 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:  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.  Use of  **-attach  **enables
### -profile  
       the argument in quotes to protect it from the shell.  The **-attach **switch may be given  multi‐
       ple times to add multiple attachments.

       The  **-nosend  **option shows the draft file that would be posted/sent on the command's standard
       output but does not post or send it.  **-send **provides the default behavior of posting or send‐
       ing the message.  It can be used to disable **-nosend**, for example, when using a shell alias.

       All other switches are passed to **post **if **-profile **is not used, or **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_

## SEE ALSO
       [_dist_(1)](https://www.chedong.com/phpMan.php/man/dist/1/markdown), [_send_(1)](https://www.chedong.com/phpMan.php/man/send/1/markdown), [_mh-format_(5)](https://www.chedong.com/phpMan.php/man/mh-format/5/markdown), [_send_(1)](https://www.chedong.com/phpMan.php/man/send/1/markdown), [_post_(8)](https://www.chedong.com/phpMan.php/man/post/8/markdown)

## 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.

nmh-1.8                                      2012-07-01                                  [_MHMAIL_(1mh)](https://www.chedong.com/phpMan.php/man/MHMAIL/1mh/markdown)
