From 4c93f66e3adf9fef2c3c1bfa80c5916655e34392 Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Thu, 1 Sep 2016 17:12:15 +0200 Subject: [PATCH] (BWDIC!) Obsolete *sendmail*++ in favour of *mta*++; obsolete *smtp*.. It is highly disturbing to go *sendmail* but talk about MTA. Let's change that. Introduce *mta*, *mta-argv0*, etc., obsolete *sendmail* stuff. And then it must be said that i dislike the method. Make it possible to assign an URL to *mta*, and if it is a SMTP one, well, then let's talk SMTP instead. Therefore obsolete *smtp*, too. Provide some small hacks to support (read: _ignore_) file:// URLs where necessary. All that for real, hopefully, in v15. Hopefully. This is BackWardInCompatible because of the changed configuration settings (VAL_SENDMAIL -> VAL_MTA, VAL_SENDMAIL_PROGNAME -> VAL_MTA_ARGV0). Yes i know it is odd to have *mta-argv0* which only applies to file-based *mta*, but *smtp-hostname*, which applies to SMTP based *mta*. In TODO we know have an idea to say mta=smtp://a:b@xy.z?no-starttls;hostname=bla But let's see what the future brings --- head.c | 26 +++- make.rc | 6 +- mk-conf.sh | 2 +- nail.1 | 464 +++++++++++++++++++++++++++++++++++-------------------------- nail.h | 16 ++- sendout.c | 105 ++++++++++---- 6 files changed, 375 insertions(+), 244 deletions(-) diff --git a/head.c b/head.c index 3c745479..767290d9 100644 --- a/head.c +++ b/head.c @@ -602,7 +602,7 @@ FL char const * myaddrs(struct header *hp) { struct name *np; - char *rv; + char const *rv, *mta; NYD_ENTER; if (hp != NULL && (np = hp->h_from) != NULL) { @@ -618,15 +618,27 @@ myaddrs(struct header *hp) /* When invoking *sendmail* directly, it's its task to generate an otherwise * undeterminable From: address. However, if the user sets *hostname*, * accept his desire */ - if (ok_vlook(smtp) != NULL || ok_vlook(hostname) != NULL) { - char *hn = nodename(1); - size_t sz = strlen(myname) + strlen(hn) + 1 +1; - rv = salloc(sz); - sstpcpy(sstpcpy(sstpcpy(rv, myname), "@"), hn); - } + if (ok_vlook(hostname) != NULL) + goto jnodename; + if (ok_vlook(smtp) != NULL || /* TODO obsolete -> mta */ + /* TODO pretty hacky for now (this entire fun), later: url_creat()! */ + ((mta = ok_vlook(mta)) != NULL && + (mta = n_servbyname(mta, NULL)) != NULL && *mta != '\0')) + goto jnodename; jleave: NYD_LEAVE; return rv; + +jnodename:{ + char *hn, *cp; + size_t i; + + hn = nodename(1); + i = strlen(myname) + strlen(hn) + 1 +1; + rv = cp = salloc(i); + sstpcpy(sstpcpy(sstpcpy(cp, myname), "@"), hn); + } + goto jleave; } FL char const * diff --git a/make.rc b/make.rc index 4186b9c0..ccbf4a6c 100644 --- a/make.rc +++ b/make.rc @@ -67,8 +67,8 @@ MAILSPOOL=`\ ## TODO values (VAL_). This is better than the current WANT_ and XYZ mess. ## TODO Start today with a few -# Path to the local MTA (Mail Transport Agent). -VAL_SENDMAIL=`\ +# Path to the local MTA (Mail-Transfer-Agent). +VAL_MTA=`\ if [ -x /usr/bin/sendmail ]; then \ echo /usr/bin/sendmail;\ elif [ -x /usr/lib/sendmail ]; then \ @@ -82,7 +82,7 @@ VAL_SENDMAIL=`\ # mailwrapper(8) is often used, which selects the required service by # looking at the name by which the program actually has been invoked. # This variable can be used to adjust this name as necessary. -VAL_SENDMAIL_PROGNAME=sendmail +VAL_MTA_ARGV0=sendmail # Default *SHELL* (sh(1) path). # Sometimes we simply invoke a command directly via execlp(2) instead of diff --git a/mk-conf.sh b/mk-conf.sh index 1fc111f5..d93ffdf4 100644 --- a/mk-conf.sh +++ b/mk-conf.sh @@ -2705,7 +2705,7 @@ ${cat} > ${tmp2}.c << \! : . libexecdir: LIBEXECDIR #endif : . mandir: MANDIR -: . sendmail(1): VAL_SENDMAIL (argv[0] = VAL_SENDMAIL_PROGNAME) +: . MTA: VAL_MTA (argv[0] = VAL_MTA_ARGV0) : . Mail spool directory: MAILSPOOL : ! diff --git a/nail.1 b/nail.1 index 4c74732c..1764450a 100644 --- a/nail.1 +++ b/nail.1 @@ -412,13 +412,17 @@ Any folder opened will be in read-only mode. If .Ar from-addr is a valid address then it specifies the envelope sender address to be -passed to the MTA as +passed to a file-based +.Va mta +(Mail-Transfer-Agent) as .Ql -f Ar address when a message is send. Shall .Ar from-addr include a user name, then the address components will be separated and -the name part will be passed to the MTA individually via +the name part will be passed to file-based +.Va mta +individually via .Ql -F Ar name . The given .Ar from-addr @@ -426,22 +430,24 @@ will also be assigned to the .Va from variable (as via .Ql -Sfrom=from-addr ) , -therefore affecting possible SMTP data transfer; -note this assignment does not cause value fixation. +therefore affecting possible SMTP +.Va mta +data transfer; note this assignment does not cause value fixation. .Pp If instead an empty string is passed as .Ar from-addr then the content of the variable .Va from -will be evaluated and used for this purpose whenever the MTA is -contacted. +will be evaluated and used for this purpose whenever the +.Va mta +is contacted. Note that \*(UA by default, without .Fl \&\&r that is, neither passes -.Ql -f +.Fl \&\&f nor -.Ql -F -flags to the MTA by itself. +.Fl \&\&F +flags to a file-based MTA by itself. . .Mx .It Fl S Ar var Ns Op = Ns value @@ -594,14 +600,13 @@ are implemented by means of setting the respective option, as via .Ek arguments that are given at the end of the command line after a .Ql -- -separator will be passed through to the mail-transfer-agent (MTA) and -persist for an entire (interactive) session \(en if the setting of +separator will be passed through to a file-based +.Va mta +(Mail-Transfer-Agent) and persist for an entire (interactive) session +\(en if the setting of .Va expandargv -allows their recognition; -MTA arguments can also be specified in the variable -.Va sendmail-arguments ; -find MTA interaction described in more detail in the documentation of -.Va sendmail . +allows their recognition; no such constraints apply to the variable +.Va mta-arguments . .\" }}} . .\" .Ss "A starter" {{{ @@ -635,11 +640,13 @@ send to names which address groups of users. .Pp \*(UA is thus the user side of the .Ux -mail system, whereas the system side (mail-transfer-agent, MTA) was +mail system, whereas the system side (Mail-Transfer-Agent, MTA) was traditionally taken by .Xr sendmail 8 , and most MTAs provide a binary of this name for compatibility purposes. -If the \*(OPal SMTP is included in the +If the \*(OPal SMTP +.Va mta +is included in the .Ic features of \*(UA then the system side is not a mandatory precondition for mail delivery. @@ -684,14 +691,11 @@ contains some suggestions. .\" .Ss "On sending mail, and non-interactive mode" {{{ .Ss "On sending mail, and non-interactive mode" . -To send a message to one or more people, using a local -mail-transfer-agent (MTA; the executable path can be set via -.Va sendmail ) -or the \*(OPal builtin SMTP (set and see the variable -.Va smtp ) -transport to actually deliver the generated mail message, \*(UA can be -invoked with arguments which are the names of people to whom the mail -will be sent, and the command line options +To send a message to one or more people, using a local or a builtin +.Va mta +(Mail-Transfer-Agent) transport to actually deliver the generated mail +message, \*(UA can be invoked with arguments which are the names of +people to whom the mail will be sent, and the command line options .Fl b and .Fl c @@ -701,8 +705,14 @@ can be used to add (blind) carbon copy receivers: $ \*(uA -s ubject -a ttach.txt bill@exam.ple # But... try it in an isolated dry-run mode first $ LC_ALL=C \*(uA -:/ -d -vv -Ssendwait \e - -b bcc@exam.ple -c cc@exam.ple -s "A subject" -. \e - "(Lovely) Bob " eric@exam.ple + -b bcc@exam.ple -c cc@exam.ple -. \e + '(Lovely) Bob ' eric@exam.ple +# With SMTP +$ LC_ALL=C \*(uA -:/ -d -vv -Sv15-compat -Ssendwait \e + -S 'mta=smtps://mylogin@exam.ple:465' -Ssmtp-auth=login \e + -S 'from=scriptreply@exam.ple' \e + -a /etc/mail.rc \e + -. eric@exam.ple .Ed . .Pp @@ -733,9 +743,9 @@ denoted by unless .Pf no Va save is set). -Messages are sent asynchronously unless the variable +Messages are sent asynchronously, without supervision, unless the variable .Va sendwait -is set, therefore send errors won't be reported. +is set, therefore send errors are not recognizable until then. . .Pp A number of @@ -762,11 +772,11 @@ hook macros may be set to automatically adjust some settings dependent on receiver, sender or subject contexts. . .Pp -Setting -.Va from -is often necessary (e.g., for -.Va smtp -transfer), and saving a copy of sent messages in a +Especially for using public mail provider accounts with the SMTP +.Va mta +it is often necessary to set +.Va from , +and saving a copy of sent messages in a .Va record may be desirable \(en as for most mailbox file targets some special syntax conventions are recognized (see the @@ -867,7 +877,7 @@ command, so that, for instance, the user can send mail to .Ql cohorts and have it go to a group of people. These aliases have nothing in common with the system wide aliases that -may be used by the MTA (mail-transfer-agent), which are subject to the +may be used by the MTA, which are subject to the .Ql name constraint of .Va expandaddr @@ -898,7 +908,7 @@ to specify variables: $ env LC_ALL=C \e \*(uA -:/ -Sv15-compat -Ssendwait -Snosave \e -Sexpandaddr=fail,-all,+addr \e - -S 'smtp=smtps://mylogin@exam.ple:465' -Ssmtp-auth=login \e + -S 'mta=smtps://mylogin@exam.ple:465' -Ssmtp-auth=login \e -S 'from=scriptreply@exam.ple' \e -s 'subject' -a attachment_file \e -. "Recipient 1 " rec2@exam.ple \e @@ -2151,7 +2161,7 @@ unusual cases become possible. The usual case is as short as: . .Pp -.Dl set smtp=smtp://USER:PASS@HOST smtp-use-starttls \e +.Dl set mta=smtp://USER:PASS@HOST smtp-use-starttls \e .Dl \ \ \ \ smime-sign smime-sign-cert=+smime.pair . .Pp @@ -2711,7 +2721,7 @@ and vertical bar .Ql | characters in order to ensure upward compatibility: the author would like to see things like -.Ql ? echo $'trouble\tahead' | cat >> in_the_shell.txt +.Ql ? echo $'trouble\etahead' | cat >> in_the_shell.txt and .Ql ? top 2 5 10; type 3 22 become possible. @@ -2875,7 +2885,7 @@ The two argument form is identical to defining a macro as via account myisp { set folder=~/mail MAIL=+syste.mbox record=+sent.mbox set from='myname@myisp.example (My Name)' - set smtp=smtp://mylogin@smtp.myisp.example + set mta=smtp://mylogin@smtp.myisp.example } .Ed . @@ -5657,8 +5667,9 @@ set to Notes: \*(UA doesn't support the .Pf no Va onehop variable \(en use command line options or -.Va sendmail-arguments -to pass options through to a MTA. +.Va mta-arguments +to pass options through to a +.Va mta . And the default global .Pa \*(UR file (which is loaded unless the @@ -6234,9 +6245,11 @@ command line option; in the latter case(s) any address may be used, then. . .Mx .It Va expandargv -Unless this variable is set additional mail-transfer-agent (MTA) +Unless this variable is set additional +.Va mta +(Mail-Transfer-Agent) arguments from the command line, as can be given after a -.Ql -- +.Fl \&\&- separator, are ignored due to safety reasons. However, if set to the special (case-insensitive) value .Ql fail , @@ -6396,15 +6409,17 @@ The address (or a list of addresses) to put into the field of the message header, quoting RFC 5322: the author(s) of the message, that is, the mailbox(es) of the person(s) or system(s) responsible for the writing of the message. -If replying to messages these addresses are handled as if they were in -the +When +.Ic reply Ns +ing to messages these addresses are handled as if they were in the .Ic alternates list. +.Pp If the machine's hostname is not valid at the Internet (for example at a dialup machine) then either this variable or .Va hostname -(\*(IN and with -.Va smtp +(\*(IN and with a defined SMTP protocol in +.Va mta .Va smtp-hostname adds even more fine-tuning capabilities), have to be set. @@ -6627,14 +6642,12 @@ i.e., in and .Ql From: fields. -Note that when -.Va smtp -transport is not used then it is normally the responsibility of the MTA -to create these fields, \*(IN in conjunction with -.Va smtp -however +Note that when SMTP transport is not used (via +.Va mta ) , +then it is normally the responsibility of the MTA to create these +fields, \*(IN in conjunction with SMTP however .Va smtp-hostname -also influences the results; +also influences the results: you should produce some test messages with the desired combination of .Va \&\&hostname , and/or @@ -6783,7 +6796,8 @@ Set this option to instead generate MBOX files which comply to RFC 4155. \*(BO By setting this option the generation of .Ql Message-ID: can be completely suppressed, effectively leaving this task up to the -mail-transfer-agent (MTA) or the SMTP server. +.Va mta +(Mail-Transfer-Agent) or the SMTP server. (According to RFC 5321 your SMTP server is not required to add this field by itself, so you should ensure that it accepts messages without a .Ql Message-ID . ) @@ -6816,9 +6830,11 @@ Note that a set .Va metoo also causes a .Ql -m -option to be passed to mail-transfer-agents (MTAs); -though most of the modern MTAs don't (no longer) document this flag, no -MTA is known which doesn't support it (for historical compatibility). +option to be passed through to the +.Va mta +(Mail-Transfer-Agent); though most of the modern MTAs no longer document +this flag, no MTA is known which doesn't support it (for historical +compatibility). . .Mx .It Va mime-allow-text-controls @@ -6944,6 +6960,160 @@ content may use the extended syntax that is described in the section Directives found in such files always take precedence (are prepended to the MIME type cache). . +. +.Mx +.It Va mta +To choose an alternate Mail-Transfer-Agent, set this option to either +the full pathname of an executable (optionally prefixed with a +.Ql file:// +protocol indicator), or \*(OPally a SMTP protocol URL, e.g., \*(IN +.Pp +.Dl smtps?://[user[:password]@]server[:port] +.Pp +(\*(OU: +.Ql [smtp://]server[:port] . ) +The default has been chosen at compie time. +All supported data transfers are executed in child processes, which +run asynchronously, and without supervision, unless either the +.Va sendwait +or the +.Va verbose +variable is set. +If such a child receives a TERM signal, it will abort and +.Va save +the message to +.Ev DEAD , +if so configured. +. +.Pp +For a file-based MTA it may be necessary to set +.Va mta-argv0 +in in order to choose the right target of a modern +.Xr mailwrapper 8 +environment. +It will be passed command line arguments from several possible sources: +from the variable +.Va mta-arguments +if set, from the command line if given and the variable +.Va expandargv +allows their use. +Argument processing of the MTA will be terminated with a +.Fl \&\&- +separator. +. +.Pp +The otherwise occurring implicit usage of the following MTA command +line arguments can be disabled by setting the boolean option +.Va mta-no-default-arguments +(which will also disable passing +.Fl \&\&- +to the MTA): +.Fl \&\&i +(for not treating a line with only a dot +.Ql \&. +character as the end of input), +.Fl \&\&m +(shall the option +.Va metoo +be set) and +.Fl \&\&v +(if the +.Va verbose +option is set); in conjunction with the +.Fl r +command line option \*(UA will also pass +.Fl \&\&f +as well as possibly +.Fl \&\&F . +. +.Pp +\*(OP \*(UA can send mail over SMTP network connections to a single +defined SMTP smarthost, the access URL of which has to be assigned to +.Va mta . +To use this mode it is helpful to read +.Sx "On URL syntax and credential lookup" . +It may be necessary to set the +.Va smtp-hostname +variable in order to use a specific combination of +.Va from , +.Va hostname +and +.Va mta +with some mail providers. +. +.Pp +.Bl -bullet -compact +.It +The plain SMTP protocol (RFC 5321) that normally lives on the +server port 25 and requires setting the +.Va smtp-use-starttls +variable to enter a SSL/TLS encrypted session state. +Assign a value like \*(IN +.Ql smtp://[user[:password]@]server[:port] +(\*(OU +.Ql smtp://server[:port] ) +to choose this protocol. +.It +The so-called SMTPS which is supposed to live on server port 465 +and is automatically SSL/TLS secured. +Unfortunately it never became a standardized protocol and may thus not +be supported by your hosts network service database +\(en in fact the port number has already been reassigned to other +protocols! +.Pp +SMTPS is nonetheless a commonly offered protocol and thus can be +chosen by assigning a value like \*(IN +.Ql smtps://[user[:password]@]server[:port] +(\*(OU +.Ql smtps://server[:port] ) ; +due to the mentioned problems it is usually necessary to explicitly +specify the port as +.Ql :465 , +however. +.It +Finally there is the SUBMISSION protocol (RFC 6409), which usually +lives on server port 587 and is practically identically to the SMTP +protocol from \*(UA's point of view beside that; it requires setting the +.Va smtp-use-starttls +variable to enter a SSL/TLS secured session state. +Assign a value like \*(IN +.Ql submission://[user[:password]@]server[:port] +(\*(OU +.Ql submission://server[:port] ) . +.El +. +. +.Mx +.It Va mta-arguments +Arguments to pass through to a file-based +.Va mta +can be given via this variable, the content of which will be split up in +a vector of arguments, to be joined onto other possible MTA options: +.Pp +.Dl set mta-arguments='-t -X \&"/tmp/my log\&"' +. +.Mx +.It Va mta-no-default-arguments +\*(BO Unless this option is set \*(UA will pass some well known +standard command line options to a file-based +.Va mta +(Mail-Transfer-Agent), see there for more. +. +.Mx +.It Va mta-argv0 +Many systems use a so-called +.Xr mailwrapper 8 +environment to ensure compatibility with +.Xr sendmail 1 . +This works by inspecting the name that was used to invoke the mail +delivery system. +If this variable is set then the mailwrapper (the program that is +actually executed when calling the file-based +.Va mta ) +will treat its contents as that name. +The default is +.Ql sendmail . +. .Mx .It Va NAIL_EXTRA_RC The name of an optional startup file to be read last. @@ -7564,81 +7734,29 @@ list. . .Mx .It Va sendmail -To use an alternate mail transport agent (MTA), -set this option to the full pathname of the program to use. -It may be necessary to set -.Va sendmail-progname -in addition. -.Pp -The MTA will be passed command line arguments from several possible -sources: from the variable -.Va sendmail-arguments -if set, from the command line if given and the variable -.Va expandargv -allows their use. -Argument processing of the MTA will be terminated with a -.Ql -- -separator. -.Pp -The otherwise occurring implicit usage of the following MTA command line -arguments can be disabled by setting the boolean option -.Va sendmail-no-default-arguments -(which will also disable passing -.Ql -- -to the MTA): -.Ql -i -(for not treating a line with only a dot -.Ql \&. -character as the end of input), -.Ql -m -(shall the option -.Va metoo -be set) and -.Ql -v -(if the -.Va verbose -option is set); in conjunction with the -.Fl r -command line option \*(UA will also pass -.Ql -f -as well as -.Ql -F . +\*(OB Predecessor of +.Va mta . . .Mx .It Va sendmail-arguments -Arguments to pass through to the Mail-Transfer-Agent can be given via -this option. -The content of this variable will be split up in a vector of arguments -which will be joined onto other possible MTA options: -.Pp -.Dl set sendmail-arguments='-t -X \&"/tmp/my log\&"' +\*(OB Predecessor of +.Va mta-arguments . . .Mx .It Va sendmail-no-default-arguments -\*(BO Unless this option is set \*(UA will pass some well known -standard command line options to the defined -.Va sendmail -program, see there for more. +\*(OB\*(BO Predecessor of +.Va mta-no-default-arguments . . .Mx .It Va sendmail-progname -Many systems use a so-called -.Xr mailwrapper 8 -environment to ensure compatibility with -.Xr sendmail 1 . -This works by inspecting the name that was used to invoke the mail -delivery system. -If this variable is set then the mailwrapper (the program that is -actually executed when calling -.Dq sendmail ) -will treat its contents as that name. -The default is -.Ql sendmail . +\*(OB Predecessor of +.Va mta-argv0 . . .Mx .It Va sendwait -\*(BO When sending a message wait until the MTA (including the builtin -SMTP one) exits before accepting further commands. +\*(BO When sending a message wait until the +.Va mta +(including the builtin SMTP one) exits before accepting further commands. .Sy Only with this variable set errors reported by the MTA will be recognizable! If the MTA returns a non-zero exit status, @@ -7853,76 +7971,20 @@ refers to the variable (or, if that contains multiple addresses, .Va sender ) . . -. .Mx .It Va smtp -\*(OP Normally \*(UA invokes the program defined via -.Va sendmail -to transfer messages, as described in -.Sx "On sending mail, and non-interactive mode" . -Setting the -.Va \&\&smtp -variable will instead cause SMTP network connections be made to the -server specified therein in order to directly submit the message. -\*(UA knows about three different -.Dq SMTP protocols : -.Pp -.Bl -bullet -compact -.It -The plain SMTP protocol (RFC 5321) that normally lives on the -server port 25 and requires setting the -.Va smtp-use-starttls -variable to enter a SSL/TLS encrypted session state. -Assign a value like \*(IN -.Ql [smtp://][user[:password]@]server[:port] -(\*(OU -.Ql [smtp://]server[:port] ) -to choose this protocol. -.It -Then the so-called SMTPS which is supposed to live on server port 465 -and is automatically SSL/TLS secured. -Unfortunately it never became a standardized protocol and may thus not -be supported by your hosts network service database -\(en in fact the port number has already been reassigned to other -protocols! -.Pp -SMTPS is nonetheless a commonly offered protocol and thus can be -chosen by assigning a value like \*(IN -.Ql smtps://[user[:password]@]server[:port] -(\*(OU -.Ql smtps://server[:port] ) ; -due to the mentioned problems it is usually necessary to explicitly -specify the port as -.Ql :465 , -however. -.It -Finally there is the SUBMISSION protocol (RFC 6409), which usually -lives on server port 587 and is practically identically to the SMTP -protocol from \*(UA's point of view beside that; it requires setting the -.Va smtp-use-starttls -variable to enter a SSL/TLS secured session state. -Assign a value like \*(IN -.Ql submission://[user[:password]@]server[:port] -(\*(OU -.Ql submission://server[:port] ) . -.El -.Pp -For more on credentials etc., please see -.Sx "On URL syntax and credential lookup" . -The SMTP transfer is executed in a child process, which runs -asynchronously unless either the -.Va sendwait -or the -.Va verbose -variable is set. -If it receives a TERM signal, it will abort and save the message to -.Ev DEAD . -. +\*(OB\*(OP To use the builtin SMTP transport, specify a SMTP URL in +.Va mta . +\*(ID For compatibility reasons a set +.Va smtp +is used in preference of +.Va mta . . .Mx Va smtp-auth .It Va smtp-auth-USER@HOST , smtp-auth-HOST , smtp-auth -\*(OP Variable chain that sets the SMTP authentication method. -Possible values are +\*(OP Variable chain that controls the SMTP +.Va mta +authentication method, possible values are .Ql none (\*(OU default), .Ql plain @@ -7939,7 +8001,7 @@ method doesn't need any user credentials, requires a user name and all other methods require a user name and a password. See \*(IN -.Va smtp , +.Va mta , .Va user and .Va password @@ -7987,19 +8049,21 @@ for specific values of sender addresses, dependent upon the variable . .Mx .It Va smtp-hostname -\*(IN Normally \*(UA uses the variable +\*(OP\*(IN Normally \*(UA uses the variable .Va from to derive the necessary .Ql USER@HOST -information to issue a +information in order to issue a .Ql MAIL FROM:<> -SMTP command. +SMTP +.Va mta +command. Setting .Va smtp-hostname can be used to use the .Ql USER from the SMTP account -.Pf ( Va smtp +.Pf ( Va mta or the .Va user variable chain) @@ -8019,8 +8083,9 @@ Setting this variable also influences the generated .It Va smtp-use-starttls-USER@HOST , smtp-use-starttls-HOST , smtp-use-starttls \*(BO\*(OP Causes \*(UA to issue a .Ql STARTTLS -command to make an SMTP session SSL/TLS encrypted, i.e., to enable -transport layer security. +command to make an SMTP +.Va mta +session SSL/TLS encrypted, i.e., to enable transport layer security. . . .Mx @@ -9609,9 +9674,9 @@ shortcut mymbox %:+mbox.mbox myrec +sent.mbox set from='Your Name ' # It may be necessary to set hostname and/or smtp-hostname -# if the "SERVER" of smtp and "domain" of from don't match. +# if the "SERVER" of mta and "domain" of from don't match. # The `urlencode' command can be used to encode USER and PASS -set smtp=(smtp[s]/submission)://[USER[:PASS]@]SERVER[:PORT] \e +set mta=(smtps?|submission)://[USER[:PASS]@]SERVER[:PORT] \e smtp-auth=login/plain... \e smtp-use-starttls @@ -9637,8 +9702,7 @@ mlsubscribe '^xfans@xfans\e.xyz$' account XooglX { set folder=~/spool/XooglX MAIL=+syste.mbox sent=+sent set from='Your Name ' - # (The plain smtp:// proto is optional) - set smtp=USER:PASS@smtp.gmXil.com smtp-use-starttls + set mta=smtp://USER:PASS@smtp.gmXil.com smtp-use-starttls } # Here is a pretty large one which does not allow sending mails @@ -9650,7 +9714,7 @@ account XooglX { account XandeX { set folder=~/spool/XandeX MAIL=+syste.mbox sent=+sent set from='Your Name ' - set smtp=smtps://USER:PASS@smtp.yaXXex.ru:465 \e + set mta=smtps://USER:PASS@smtp.yaXXex.ru:465 \e hostname=yaXXex.com smtp-hostname= } @@ -9722,7 +9786,7 @@ account XandeX { # Load an encrypted ~/.netrc by uncommenting the next line #set netrc-pipe='gpg -qd ~/.netrc.pgp' - set smtp=smtps://smtp.yXXXXx.ru:465 \e + set mta=smtps://smtp.yXXXXx.ru:465 \e smtp-hostname= hostname=yXXXXx.com set pop3-keepalive=240 pop3-no-apop-pop.yXXXXx.ru ghost xp fi pop3s://pop.yXXXXx.ru diff --git a/nail.h b/nail.h index df183ebf..bc73cef6 100644 --- a/nail.h +++ b/nail.h @@ -1527,6 +1527,12 @@ ok_b_emptybox, ok_b_mime_alternative_favour_rich, ok_v_mime_counter_evidence, /* {posnum=1} */ ok_v_mimetypes_load_control, + /* TODO: v15 (not yet due to <-> sendmail): {defval=VAL_MTA} */ + ok_v_mta, + ok_v_mta_arguments, + ok_b_mta_no_default_arguments, + /* TODO v15: (not yet due to <-> sendmail-progname {defval=VAL_MTA_ARGV0} */ + ok_v_mta_argv0, ok_v_NAIL_EXTRA_RC, /* {name=NAIL_EXTRA_RC} */ ok_b_NAIL_NO_SYSTEM_RC, /* {import=1} */ @@ -1577,10 +1583,10 @@ ok_b_SYSV3, /* {env=1} */ ok_v_sendcharsets, ok_b_sendcharsets_else_ttycharset, ok_v_sender, - ok_v_sendmail, /* {defval=VAL_SENDMAIL} */ - ok_v_sendmail_arguments, - ok_b_sendmail_no_default_arguments, - ok_v_sendmail_progname, /* {defval=VAL_SENDMAIL_PROGNAME} */ +ok_v_sendmail, +ok_v_sendmail_arguments, +ok_b_sendmail_no_default_arguments, +ok_v_sendmail_progname, ok_b_sendwait, ok_b_showlast, ok_b_showname, @@ -1601,7 +1607,7 @@ ok_b_SYSV3, /* {env=1} */ ok_v_smime_sign_cert, ok_v_smime_sign_include_certs, ok_v_smime_sign_message_digest, - ok_v_smtp, +ok_v_smtp, ok_v_smtp_auth, ok_v_smtp_auth_password, ok_v_smtp_auth_user, diff --git a/sendout.c b/sendout.c index 453d99af..3f256fdd 100644 --- a/sendout.c +++ b/sendout.c @@ -434,7 +434,7 @@ _sendbundle_setup_creds(struct sendbundle *sbp, bool_t signing_caps) bool_t v15, rv = FAL0; char *shost, *from; #ifdef HAVE_SMTP - char *smtp; + char const *smtp; #endif NYD_ENTER; @@ -454,9 +454,15 @@ _sendbundle_setup_creds(struct sendbundle *sbp, bool_t signing_caps) } #ifdef HAVE_SMTP - if ((smtp = ok_vlook(smtp)) == NULL) { - rv = TRU1; - goto jleave; + if ((smtp = ok_vlook(smtp)) == NULL) { /* TODO v15 url_creat(,ok_vlook(mta)*/ + char const *proto; + + /* *smtp* OBSOLETE message in mta_start() */ + if ((smtp = ok_vlook(mta)) == NULL || + (proto = n_servbyname(smtp, NULL)) == NULL || *proto == '\0') { + rv = TRU1; + goto jleave; + } } if (!url_parse(&sbp->sb_url, CPROTO_SMTP, smtp)) @@ -1156,17 +1162,50 @@ _transfer(struct sendbundle *sbp) static bool_t __mta_start(struct sendbundle *sbp) { - char const **args = NULL, *mta, *smtp; pid_t pid; sigset_t nset; - bool_t rv = FAL0; + char const **args, *mta; + bool_t rv; NYD_ENTER; - if ((smtp = ok_vlook(smtp)) == NULL) { + if((mta = ok_vlook(smtp)) != NULL){ + OBSOLETE(_("please don't use *smtp*, but assign an SMTP URL to *mta*")); + /* For *smtp* the smtp:// protocol was optional; be simple: don't check + * that *smtp* is misused with file:// or so */ + if(n_servbyname(mta, NULL) == NULL) + mta = savecat("smtp://", mta); + rv = TRU1; + }else{ + char const *proto; + + if((proto = ok_vlook(sendmail)) != NULL) + OBSOLETE(_("please use *mta* instead of *sendmail*")); + if((mta = ok_vlook(mta)) == NULL){ /* TODO v15: mta = ok_vlook(mta); */ + if(proto == NULL){ + mta = VAL_MTA; + rv = FAL0; + }else + rv = TRU1; + } + /* TODO for now this is pretty hacky: in v15 we should simply create + * TODO an URL object; i.e., be able to do so, and it does it right + * TODO I.e.,: url_creat(&url, ok_vlook(mta)); */ + else if((proto = n_servbyname(mta, NULL)) != NULL){ + if(*proto == '\0'){ + mta += sizeof("file://") -1; + rv = FAL0; + }else + rv = TRU1; + }else + rv = FAL0; + } + + if(!rv){ char const *mta_base; - if((mta = file_expand(mta_base = ok_vlook(sendmail))) == NULL){ - n_err(_("*sendmail* variable expansion failure: \"%s\""), mta_base); + if((mta = file_expand(mta_base = mta)) == NULL){ + n_err(_("*mta* variable expansion failure: %s\n"), + n_shell_quote_cp(mta_base, FAL0)); goto jstop; } @@ -1177,7 +1216,7 @@ __mta_start(struct sendbundle *sbp) goto jleave; } } else { - UNINIT(mta, NULL); /* Silence cc */ + UNINIT(args, NULL); #ifndef HAVE_SMTP n_err(_("No SMTP support compiled in\n")); goto jstop; @@ -1209,13 +1248,14 @@ jstop: sigaddset(&nset, SIGTTOU); freopen("/dev/null", "r", stdin); #ifdef HAVE_SMTP - if (smtp != NULL) { + if (rv) { prepare_child(&nset, 0, 1); if (smtp_mta(sbp)) _exit(EXIT_OK); } else #endif { + char const *ecp; int e; prepare_child(&nset, fileno(sbp->sb_input), -1); @@ -1226,9 +1266,9 @@ jstop: lseek(0, 0, SEEK_SET); execv(mta, UNCONST(args)); e = errno; - smtp = (e != ENOENT) ? strerror(e) - : _("executable not found (adjust *sendmail* variable)"); - n_err(_("Cannot start \"%s\": %s\n"), mta, smtp); + ecp = (e != ENOENT) ? strerror(e) + : _("executable not found (adjust *mta* variable)"); + n_err(_("Cannot start %s: %s\n"), n_shell_quote_cp(mta, FAL0), ecp); } savedeadletter(sbp->sb_input, 1); n_err(_("... message not sent\n")); @@ -1236,13 +1276,11 @@ jstop: } if ((options & (OPT_DEBUG | OPT_VERB)) || ok_blook(sendwait)) { - if (wait_child(pid, NULL)) - rv = TRU1; - else + if (!(rv = wait_child(pid, NULL))) _sendout_error = TRU1; } else { - rv = TRU1; free_child(pid); + rv = TRU1; } jleave: NYD_LEAVE; @@ -1253,28 +1291,42 @@ static char const ** __mta_prepare_args(struct name *to, struct header *hp) { size_t vas_cnt, i, j; - char **vas, *cp; - char const **args; + char **vas; + char const **args, *cp, *cp_v15compat; bool_t snda; NYD_ENTER; - if ((cp = ok_vlook(sendmail_arguments)) == NULL) { + if((cp_v15compat = ok_vlook(sendmail_arguments)) != NULL) + OBSOLETE(_("please use *mta-arguments*, not *sendmail-arguments*")); + if((cp = ok_vlook(mta_arguments)) == NULL) + cp = cp_v15compat; + if ((cp /* TODO v15: = ok_vlook(mta_arguments)*/) == NULL) { vas_cnt = 0; vas = NULL; } else { /* Don't assume anything on the content but do allocate exactly j slots; * like this getrawlist will never overflow (and return -1) */ j = strlen(cp); - vas = ac_alloc(sizeof(*vas) * j); + vas = salloc(sizeof(*vas) * j); vas_cnt = (size_t)getrawlist(FAL0, vas, j, cp, j); } i = 4 + smopts_cnt + vas_cnt + 4 + 1 + count(to) + 1; args = salloc(i * sizeof(char*)); - args[0] = ok_vlook(sendmail_progname); + if((cp_v15compat = ok_vlook(sendmail_progname)) != NULL) + OBSOLETE(_("please use *mta-argv0*, not *sendmail-progname*")); + if((cp = ok_vlook(mta_argv0)) == NULL) + cp = cp_v15compat; + if(cp == NULL) + cp = VAL_MTA_ARGV0; + args[0] = cp/* TODO v15: = ok_vlook(mta_argv0) */; if ((snda = ok_blook(sendmail_no_default_arguments))) + OBSOLETE(_("please use *mta-no-default-arguments*, " + "not *sendmail-no-default-arguments*")); + snda |= ok_blook(mta_no_default_arguments); + if ((snda /* TODO v15: = ok_blook(mta_no_default_arguments)*/)) i = 1; else { args[1] = "-i"; @@ -1329,9 +1381,6 @@ __mta_prepare_args(struct name *to, struct header *hp) if (!(to->n_type & GDEL)) args[i++] = to->n_name; args[i] = NULL; - - if (vas != NULL) - ac_free(vas); NYD_LEAVE; return args; } @@ -1343,9 +1392,9 @@ __mta_debug(struct sendbundle *sbp, char const *mta, char const **args) char *buf; NYD_ENTER; - n_err(_(">>> MTA: \"%s\", arguments:"), mta); + n_err(_(">>> MTA: %s, arguments:"), n_shell_quote_cp(mta, FAL0)); for (; *args != NULL; ++args) - n_err(" \"%s\"", *args); + n_err(" %s", n_shell_quote_cp(*args, FAL0)); n_err("\n"); fflush_rewind(sbp->sb_input); -- 2.11.4.GIT