.\"
.\" %nmhwarning%
.\"
-.TH SEND %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
+.TH SEND %manext1% "August 14, 2016" "%nmhversion%"
.SH NAME
send \- send a message
.SH SYNOPSIS
.RB [ \-forward " | " \-noforward ]
.RB [ \-mime " | " \-nomime ]
.RB [ \-msgid " | " \-nomsgid ]
+.RB [ \-messageid
+.IR localname " | " random ]
.RB [ \-push " | " \-nopush ]
.RB [ \-split
.IR seconds ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-watch " | " \-nowatch ]
+.RB [ \-mts
+.IR smtp " | " sendmail/smtp " | " sendmail/pipe ]
+.RB [ \-sendmail
+.IR program ]
.RB [ \-server
.IR servername ]
.RB [ \-port
.IR ssf ]
.RB [ \-saslmech
.IR mechanism ]
+.RB [ \-authservice
+.IR service ]
.RB [ \-snoop ]
.RB [ \-user
.IR username ]
.RB [ \-tls ]
+.RB [ \-initialtls ]
.RB [ \-notls ]
.RB [ \-width
.IR columns ]
.RB [ file
-\&...]
+\&...]
.RB [ \-version ]
.RB [ \-help ]
-.RB [ \-attach
-.IR header-field-name ]
-.RB [ \-noattach ]
-.RB [ \-attachformat
-.IR 0 " | " 1 " | " 2 ]
.ad
.SH DESCRIPTION
.B Send
.B send
are actually performed by
.BR post .
-
.PP
-By default the draft is scanned for a header named
-.IR Nmh-Attachment .
+Before
+.B send
+gives the message to
+.B post
+for delivery, the message is processed by
+.B mhbuild
+to perform any necessary MIME encoding of the outgoing message. This
+can be changed by the
+.I buildmimeproc
+profile component.
+.B mhbuild
+is invoked with the
+.B \-auto
+switch, so
+.B mhbuild
+directives are not processed by default. See
+.IR mhbuild (1)
+for more information.
+.PP
+.B mhbuild
+will scan the message draft for a header named
+.IR Attach .
The draft is converted to a MIME message if one or more matches are found.
-This conversion occurs before all other processing. The header name
-can be changed with the
-.B \-attach
-option. This behavior can be disabled completely with the
-.B \-noattach
-option.
+This conversion occurs before all other processing. The
+.IR whatnow (1)
+man page describes the user interface for managing MIME attachments via
+this mechanism.
.PP
The first part of the MIME message is the draft body if that body contains
any non-blank characters.
-The body of each header field whose name matches the
-.I header-field-name
-is interpreted as a file name, and each file named is included as a separate
+The body of each
+.I Attach
+header field is interpreted as a file name, and each file named is included as a separate
part in the MIME message.
.PP
-For file names with dot suffixes, the profile is scanned for a
+Determination of the content MIME type inserted into the Content-Type
+header for each part depends on how the
+.B nmh
+installation was configured. If a program, such as
+.B file
+with a
+.B \-\-mime
+or
+.B \-i
+option, was found that can specify the type of a file as a MIME type
+string, then that will be used. To determine if your
+.B nmh
+was so configured, run
+.B mhparam mimetypeproc
+and see if a non-empty string is displayed.
+.PP
+If your
+.B nmh
+was not configured with a program to specify a file type as a MIME
+string, then a different method is used to determine the content-type
+string. For file names with dot suffixes, the profile is scanned for a
.I mhshow-suffix-
entry for that suffix.
The content-type for the part is taken from that profile entry if a match is
If no match is found or the file does not have a dot suffix, the content-type
is text/plain if the file contains only ASCII characters or application/octet-stream
if it contains characters outside of the ASCII range. See
-.BR mhshow (1)
+.IR mhshow (1)
for more details and example syntax.
.PP
-Each part contains a name attribute that is the last component of the path name.
-A
-.I x-unix-mode
-attribute containing the file mode accompanies each part.
-Finally, a description attribute is generated by running the
-.I file
-command on the file.
-.PP
-The
-.B -attachformat
-option specifies the MIME header field formats: a value of
-.B 0
-includes the
-.I x-unix-mode
-attribute as noted above. A value of
-.BR 1 ,
-the default,
-suppresses that, puts the file name in the
-\*(lqContent-Description\*(rq header, and
-adds a \*(lqContent-Disposition\*(rq header. A value of
-.B 2
-adds the file
-.I modification-date
-parameter to the \*(lqContent-Disposition\*(rq header. You can
-specify one value in your profile, and override it for individual
-messages at the
-.I whatnow
-prompt.
-.PP
-Here are example message part headers, for an attachment, for each of the
-.B -attachformat
-values:
+Each attached MIME part contains a
+\*(lqContent-Description\*(rq header that includes the filename, and
+adds a \*(lqContent-Disposition\*(rq header.
+Here is an example of MIME part headers for an attachment:
.PP
.nf
--attachformat 0:
-Content-Type: text/plain; name="VERSION"; x-unix-mode="0644";
- charset="us-ascii"
-Content-Description: ASCII text
-
--attachformat 1:
Content-Type: text/plain; name="VERSION"; charset="us-ascii"
Content-Description: VERSION
Content-Disposition: attachment; filename="VERSION"
-
--attachformat 2:
-Content-Type: text/plain; name="VERSION"; charset="us-ascii"
-Content-Description: VERSION
-Content-Disposition: attachment; filename="VERSION"; modification-date="Mon, 19 Dec 2005 22:39:51 -0600"
.fi
.PP
+See
+.IR mhbuild (1)
+for explanation of how the Content-Disposition value is selected.
+.PP
If
.B \-push
is specified,
.B nmh
draft folder facility. This is an advanced (and highly
useful) feature. Consult the
-.BR mh-draft (5)
+.IR mh-draft (5)
man page for more
information.
.PP
new message with a minimal set of headers. Included in the body of the
message will be a copy of the message sent to the sighted recipients.
.PP
-If a \*(lqDcc:\*(rq field is encountered, its addresses will be used for
+If a \*(lqDcc:\*(rq field is encountered and the
+.B sendmail/pipe
+mail transport method is not in use, its addresses will be used for
delivery, and the \*(lqDcc:\*(rq field will be removed from the message. The
blind recipients will receive the same message sent to the sighted
recipients. *WARNING* Recipients listed in the \*(lqDcc:\*(rq field receive no
is specified, then a \*(lqMessage\-ID:\*(rq field will also
be added to the message.
.PP
+The
+.B \-messageid
+switch selects the style used for the part appearing after the @
+in \*(lqMessage\-ID:\*(rq, \*(lqResent\-Message\-ID:\*(rq, and
+\*(lqContent\-ID:\*(rq header fields. The two acceptable options are
+.B localname
+(which is the default),
+and
+.BR random .
+With
+.BR localname ,
+the local hostname is used. With
+.BR random ,
+a random sequence of characters is used instead. Note that the
+.B \-msgid
+switch must be enabled for this switch to have any effect.
+.PP
If
.B send
is re\-distributing a message (when invoked by
.B send
as to how long it should make header lines containing addresses.
.PP
+The mail transport system default is provided in
+.I %nmhetcdir%/mts.conf
+but can be overriiden here with the
+.B \-mts
+switch.
+.PP
+If nmh is using as its mail transport system
+.BR sendmail/pipe ,
+the
+.B \-sendmail
+switch can be used to override the default
+.B sendmail
+program.
+.PP
If nmh is using the SMTP MTA, the
.B \-server
and the
.B \-port
switches can be used to override the default mail server (defined by the
-.I %etcdir%/mts.conf
+.I %nmhetcdir%/mts.conf
.RI servers
entry). The
.B \-snoop
switch can be used to view the SMTP transaction. (Beware that the
SMTP transaction may contain authentication information either in
-plaintext or easily decoded base64.)
+plaintext or easily decoded base64.) If
+.B \-saslmech xoauth2
+is used, the HTTP transaction is also shown.
.PP
If
.B nmh
the use of SASL authentication with the SMTP MTA. Depending on the
SASL mechanism used, this may require an additional password prompt from the
user (but the
-.RI \*(lq \&.netrc \*(rq
-file can be used to store this password).
+.I netrc
+file can be used to store this password, as described in the
+mh-profile(5) man page). The
.B \-saslmech
switch can be used to select a particular SASL mechanism,
-and the the
+and the
.B \-user
-switch can be used to select a authorization userid
-to provide to SASL other than the default.
+switch can be used to select a authorization userid to provide to SASL
+other than the default. The credentials profile entry in the
+mh\-profile(5) man page describes the ways to supply a username and
+password.
.PP
-If SASL authentication is successful,
+If SASL authentication is successful,
.BR nmh
will attempt to negotiate a security layer for session encryption.
Encrypted data is labelled with `(encrypted)' and `(decrypted)' when
viewing the SMTP transaction with the
.B \-snoop
-switch. The
+switch; see the
+.B post
+man page description of
+.B \-snoop
+for its other features.
+The
.B \-saslmaxssf
switch can be used to select the maximum value of the Security Strength Factor.
This is an integer value and the exact meaning of this value depends on the
.PP
If
.B nmh
+has been compiled with OAuth support, the
+.B \-saslmech xoauth2
+switch will enable OAuth authentication. The
+.B \-user
+switch must be used, and the
+.I user-name
+must be an email address the user has for the service, which must
+be specified with the
+.B \-authservice
+.I service
+switch. Before using this, the user must authorize nmh by running
+.B mhlogin
+and grant authorization to that account. See the
+.B mhlogin
+man page for more details.
+.PP
+If
+.B nmh
has been compiled with TLS support, the
.B \-tls
and
-.B \-notls
-switches will require and disable the negotiation of TLS support when connecting to the
-SMTP MTA. Encrypted data is labelled with `(tls-encrypted)' and
+.B \-initialtls
+switches will require the negotiation of TLS when
+connecting to the SMTP MTA. The
+.B \-tls
+switch will negotiate TLS as part of the normal SMTP protocol
+using the STARTTLS command. The
+.B \-initialtls
+will negotiate TLS immediately after the connection has
+taken place, before any SMTP commands are sent or received. Encrypted data
+is labelled with `(tls-encrypted)' and
`(tls-decrypted)' when viewing the SMTP transction with the
.B \-snoop
-switch.
+switch; see the
+.B post
+man page description of
+.B \-snoop
+for its other features.
+The
+.B \-notls
+switch will disable all attempts to negotiate TLS.
+.PP
+If port 465 is specified and none of the TLS switches were enabled,
+.B \-initialtls
+will be implied if TLS support was compiled in. Though port 465 for
+SMTPS (SMTP over SSL) was deregistered by IANA in 1998, it is still
+used for that service.
.PP
The files specified by the profile entry \*(lqAliasfile:\*(rq and any
additional alias files given by the
.BR \-alias ,
can be named).
See
-.BR mh\-alias (5)
+.IR mh\-alias (5)
for more information.
-
+.SS Selection based on sender address: sendfrom
+One or more
+.I sendfrom
+profile components can be used to select a mail server address, mail server
+port, or any other switch that can be supplied to
+.BR post .
+It works by first looking at the sender address and domain name in the
+message draft, as described below.
+It then looks for a corresponding profile entry, which contains the
+.B post
+switches.
+To enable, add profile entries of the form:
+.PP
+.RS 5
+.RI sendfrom- "address/domain name" : " post switches"
+.RE
+.PP
+The email address is extracted from the Envelope-From: header, if not blank,
+the Sender: header, or the From: header line in the message draft.
+Multiple profile entries, with different email addresses or domain names, are
+supported.
+This allows different switches to
+.BR post ,
+such as -user, to be associated with different email addresses.
+If a domain name is used, it matches all users in that domain.
+.PP
+Here is an example profile entry using OAuth for an account hosted by gmail:
+.PP
+.nf
+.RS 5
+sendfrom-gmail_address@example.com: -saslmech xoauth2
+.RS 5
+-authservice gmail -tls -server smtp.gmail.com
+-user gmail_login@example.com
+.RE
+.RE
+.fi
+.PP
+(Indentation indicates a continued line, as supported in MH profiles.)
+The username need not be the same as the sender address, which was extracted
+from the appropriate header line as noted above.
+.PP
+Here are example profile entries that use an nmh credentials file:
+.PP
+.nf
+.RS 5
+credentials: file:nmhcreds
+sendfrom-sendgrid_address@example.com: -sasl -tls
+.RS 5
+-server smtp.sendgrid.net
+.RE
+sendfrom-outbound.att.net: -sasl -initialtls
+.RS 5
+-server outbound.att.net -port 465
+.RE
+sendfrom-fastmail.com: -initialtls -sasl -saslmech LOGIN
+.RS 5
+-server smtps-proxy.messagingengine.com -port 80
+.RE
+.RE
+.fi
+.PP
+where nmhcreds is in the user's nmh directory (from the Path profile component)
+and contains:
+.PP
+.nf
+.RS 5
+machine smtp.sendgrid.net
+.RS 5
+login sendgrid_login@example.com
+password ********
+.RE
+machine outbound.att.net
+.RS 5
+login att_login@example.com
+password ********
+.RE
+machine smtps-proxy.messagingengine.com
+.RS 5
+login fastmail_login@example.com
+password ********
+.RE
+.RE
+.fi
+.PP
+For more information on authentication to mail servers, see the
+.IR mhlogin (1)
+man page for OAuth services, and
+.IR mh-profile (5)
+man page for login credentials.
+.PP
.SH FILES
.fc ^ ~
.nf
-.ta \w'%etcdir%/ExtraBigFileName 'u
+.ta \w'%nmhetcdir%/ExtraBigFileName 'u
^$HOME/\&.mh\(ruprofile~^The user profile
.fi
-
.SH "PROFILE COMPONENTS"
.fc ^ ~
.nf
^Signature:~^To determine the user's mail signature
^mailproc:~^Program to post failure notices
^postproc:~^Program to post the message
+^sendfrom-address:~^Switches to post for sender address
+^sendfrom-domain:~^Switches to post for sender domain name
.fi
-
.SH "SEE ALSO"
-comp(1), dist(1), forw(1), repl(1), mh\-alias(5), post(8)
-
+.IR comp (1),
+.IR dist (1),
+.IR file (1),
+.IR forw (1),
+.IR mhbuild (1),
+.IR mhparam (1),
+.IR mhlogin (1),
+.IR repl (1),
+.IR whatnow (1),
+.IR mh\-alias (5),
+.IR mh\-profile (5),
+.IR mh\-tailor (5),
+.IR post (8)
.SH DEFAULTS
.nf
.RB ` file "' defaults to <mh\-dir>/draft"
-.RB ` \-alias "' defaults to %etcdir%/MailAliases"
+.RB ` \-alias "' defaults to %nmhetcdir%/MailAliases"
.RB ` \-nodraftfolder '
.RB ` \-nofilter '
.RB ` \-format '
.RB ` \-forward '
.RB ` \-nomime '
.RB ` \-nomsgid '
+.RB ` "\-messageid\ localname" '
.RB ` \-nopush '
.RB ` \-noverbose '
.RB ` \-nowatch '
.RB ` "\-width\ 72" '
-.RB ` "\-attach\ Nmh-Attachment" '
-.RB ` "\-attachformat\ 1" '
.fi
-
.SH CONTEXT
None
-
.SH BUGS
Under some configurations, it is not possible to monitor the mail delivery
transaction;