配置Outlook XOAUTH2后git send-email报No SASL mechanism found错误求助
使用git send-email + Outlook XOAUTH2发送补丁时的SASL机制错误解决
问题详情
我正尝试给一个基于邮件的Git项目提交代码,用git send-email发送补丁。已经配置了Outlook账户的XOauth2认证,但执行命令:
git send-email --annotate -1 --subject-prefix="PATCH aerc/wiki" --smtp-debug=1 --no-cc
时触发错误:
No SASL mechanism found at /usr/share/perl5/vendor_perl/Authen/SASL.pm line 76. at /usr/share/perl5/core_perl/Net/SMTP.pm line 211.
我试过从Arch包管理器安装perl-authen-sasl,但问题没解决。以下是我的Git配置:
remote.origin.url=git@git.sr.ht:~rjarry/aerc remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master branch.wiki.remote=origin branch.wiki.merge=refs/heads/wiki format.subjectprefix=PATCH aerc format.notes=true sendemail.to=~rjarry/aerc-devel@lists.sr.ht sendemail.validate=true sendemail.smtpserver=smtp.office365.com sendemail.smtpuser=name#outlook.com sendemail.smtpencryption=tls sendemail.smtpserverport=587 sendemail.smtpauth=XOAUTH2 notes.rewriteref=refs/notes/commits notes.rewritemode=concatenate user.name=Name user.email=name@outlook.com credential.smtp://smtp.office365.com:587.oauthclientid=ClIENTID credential.smtp://smtp.office365.com:587.oauthclientsecret=CLIENTSECRET credential.smtp://smtp.office365.com:587.oauthauthurl=https://login.microsoftonline.com/common/oauth2/v2.0/authorize credential.smtp://smtp.office365.com:587.oauthtokenurl=https://login.microsoftonline.com/common/oauth2/v2.0/token credential.smtp://smtp.office365.com:587.oauthscopes=https://outlook.office.com/SMTP.Send credential.smtp://smtp.office365.com:587.oauthredirecturl=http://localhost/
解决步骤
- 安装XOauth2专用SASL包:Arch上仅安装
perl-authen-sasl不够,还需安装perl-authen-sasl-xoauth2来提供XOauth2的SASL机制支持,执行命令:sudo pacman -S perl-authen-sasl-xoauth2 - 修正SMTP用户名:配置中
sendemail.smtpuser的值是name#outlook.com,需改为完整邮箱地址name@outlook.com,XOauth2认证要求用户名与邮箱账户匹配。 - 修正凭证拼写错误:配置里的
ClIENTID存在拼写错误(多了一个大写L),需改为CLIENTID,确保客户端ID和密钥准确无误。 - 验证SASL机制加载:运行以下Perl脚本确认XOauth2机制是否正常加载:
若脚本输出成功提示,说明依赖问题已解决,可重新尝试发送补丁。use Authen::SASL; my $sasl = Authen::SASL->new(mechanism => 'XOAUTH2'); print "SASL机制加载成功\n" if $sasl;
内容的提问来源于stack exchange,提问作者Amulya Mohan
相关产品推荐
相关产品推荐

