Git 2.33 (Q3 2021), proposes another way to use/debug sendmail: "git send-email
"(man) learned the --sendmail-cmd
command line option and the sendemail.sendmailCmd
configuration variable, which is a more sensible approach than the current way of repurposing the "smtp-server
" that is meant to name the server to instead name the command to talk to the server.
So you can specify your own sendmail-like program, which can be used to debug/put more traces.
See commit cd5b33f (14 May 2021) by Gregory Anders (gpanders
).
(Merged by Junio C Hamano -- gitster
-- in commit 1359972, 14 Jun 2021)
git-send-email
: add option to specify sendmail command
Signed-off-by: Gregory Anders
The sendemail.smtpServer configuration option and --smtp-server
command line option both support using a sendmail-like program to send emails by specifying an absolute file path.
However, this is not ideal for the following reasons:
- It overloads the meaning of smtpServer (now a program is being used
for the server?)
- It doesn't allow for non-absolute paths, arguments, or arbitrary
scripting
Requiring an absolute path is bad for portability, as the same program may be in different locations on different systems.
If a user wishes to pass arguments to their program, they have to use the smtpServerOption
option, which is cumbersome (as it must be repeated for each option) and doesn't adhere to normal Git conventions.
Introduce a new configuration option sendemail.sendmailCmd
as well as a command line option --sendmail-cmd
that can be used to specify a command (with or without arguments) or shell expression to run to send email.
The name of this option is consistent with --to-cmd
and --cc-cmd.
This invocation honors the user's $PATH
so that absolute paths are not necessary.
Arbitrary shell expressions are also supported, allowing users to do basic scripting.
Give this option a higher precedence over --smtp-server
and sendemail.smtpServer
, as the new interface is more flexible.
For backward compatibility, continue to support absolute paths in --smtp-server
and sendemail.smtpServer
.
git send-email
now includes in its man page:
--sendmail-cmd=<command>
Specify a command to run to send the email.
The command should be sendmail-like; specifically, it must support the -i
option.
The command will be executed in the shell if necessary.
Default
is the value of sendemail.sendmailcmd
.
If unspecified, and if
--smtp-server
is also unspecified, git-send-email
will search
for sendmail
in /usr/sbin
, /usr/lib
and $PATH
.
git send-email
now includes in its man page:
For backward compatibility, this option can also specify a full pathname
of a sendmail-like program instead; the program must support the -i
option.
This method does not support passing arguments or using plain
command names.
For those use cases, consider using --sendmail-cmd
instead.