git - 我们如何正确验证 git send-email 配置设置?

标签 git git-send-email

使用 git 2.5。

是否有一种聪明的或官方的方法来验证 git send-email 是否能够连接到我的 smtp 服务器并进行身份验证?我已经配置了 git,但似乎无法成功使用git send-email

当我执行git send-email <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7fafaa3b8eabaaea3b2a4a397b2afb6baa7bbb2f9b4b8ba" rel="noreferrer noopener nofollow">[email protected]</a>时我要么看到:

[Net::SMTP] 连接在/usr/libexec/git-core/git-send-email 第 1348 行关闭。

或者,当在我的配置中使用 tls 时,我看到:

死在/usr/libexec/git-core/git-send-email 第 1348 行。

我的~/.gitconfig似乎是正确的:

[user]
  name = John Jacob Jingleheimer Schmidt
  email = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93f9f9f9e0d3f6ebf2fee3fff6bdf0fcfe" rel="noreferrer noopener nofollow">[email protected]</a>
[sendemail]
  smtpserver = mail.example.com
  smtpuser = *****
  smtpserverport = **
  confirm = auto
  smtpauth = PLAIN
  smtpencryption = tls

解决这个问题很麻烦。有没有某种git send-email --verify命令可以清楚地告诉我我的配置是否正确?

最佳答案

Git 2.33(2021 年第 3 季度)提出了另一种使用/调试 sendmail 的方法:“ git send-email ( man ) 学习了 --sendmail-cmd 命令行选项和 sendemail.sendmailCmd 配置变量,这是一种更明智的方法与当前重新利用“smtp-server”的方式相比,该方式旨在命名服务器,而不是命名与服务器通信的命令。

因此您可以指定自己的类似 sendmail 的程序,该程序可用于调试/放置更多跟踪。

请参阅 commit cd5b33f(2021 年 5 月 14 日),作者:Gregory Anders ( gpanders )
(由 Junio C Hamano -- gitster -- merge 于 commit 1359972 ,2021 年 6 月 14 日)

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:

  1. It overloads the meaning of smtpServer (now a program is being used for the server?)
  2. 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 现在包含在其 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 现在包含在其 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.

关于git - 我们如何正确验证 git send-email 配置设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35922797/

相关文章:

git - 如何自动将 `git commit amend` *附加*到最后的提交消息?

git - 在 git bisect run 期间运行两个命令

git ls-remote --tags : how to get date information?

ruby-on-rails - heroku 控制台显示来自 git 部署的最新 sha 哈希

eclipse - 如何让新分支显示在 Eclipse Git 远程跟踪中?