From: Florian Klink Date: Tue, 28 Nov 2017 00:49:04 +0000 (+0100) Subject: git-send-email: honor $PATH for sendmail binary X-Git-Tag: v2.16.0-rc0~59^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1ab2fd4f397d8891f5345f876d42ab360859bcca git-send-email: honor $PATH for sendmail binary This extends git-send-email to also consider sendmail binaries in $PATH after checking the (fixed) list of /usr/sbin and /usr/lib, and before falling back to localhost. Signed-off-by: Florian Klink Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index bac9014ac7..8060ea35c5 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -203,9 +203,9 @@ a password is obtained using 'git-credential'. specify a full pathname of a sendmail-like program instead; the program must support the `-i` option. Default value can be specified by the `sendemail.smtpServer` configuration - option; the built-in default is `/usr/sbin/sendmail` or - `/usr/lib/sendmail` if such program is available, or - `localhost` otherwise. + option; the built-in default is to search for `sendmail` in + `/usr/sbin`, `/usr/lib` and $PATH if such program is + available, falling back to `localhost` otherwise. --smtp-server-port=:: Specifies a port different from the default port (SMTP diff --git a/git-send-email.perl b/git-send-email.perl index 2208dcc213..edcc6d3469 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -885,7 +885,9 @@ sub expand_one_alias { } if (!defined $smtp_server) { - foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) { + my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail ); + push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH}; + foreach (@sendmail_paths) { if (-x $_) { $smtp_server = $_; last;