c# - Netcore 2.2 - Docker 容器无法发送邮件
问题描述
我目前正在将一个应用程序部署到 docker 容器中,该应用程序具有发送邮件的功能(基于 c# netcore 2.2)但我无法发送邮件(虽然意味着我可以从本地主机发送邮件)docker 中的异常消息
System.ComponentModel.Win32Exception:GSSAPI 操作失败并出现错误 - 未指定的 GSS 失败。次要代码可能会提供更多信息(找不到领域“xxx.yyyy”的 KDC)。在 System.Net.Security.NegotiateStreamPal.AcquireCredentialsHandle(String package, Boolean isServer, NetworkCredential credential) 在 System.Net.NTAuthentication.Initialize(Boolean isServer, String package, NetworkCredential credential, String spn, ContextFlagsPal requestedContextFlags, ChannelBinding channelBinding) 在系统。 System.Net.Mail.SmtpConnection.SetContextAndTryAuthenticate(ISmtpAuthenticationModule 模块,NetworkCredential 凭据,
在 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) 在 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) 在 System.Net.Mail.SmtpClient.GetConnection() 在 System.Net .Mail.SmtpClient.Send(MailMessage message) --- 内部异常堆栈跟踪结束 --- 在 System.Net.Mail.SmtpClient.Send(MailMessage message)
我尝试了谷歌的一些帮助,但不能,所以请帮助我,谢谢
解决方案
当您发送具有 GSSAPI 身份验证类型的邮件时,Linux 上的 dotnet 似乎存在问题: https://github.com/dotnet/runtime/issues/2174,https://github.com/dotnet/runtime/issues /25885 , https://github.com/dotnet/runtime/issues/27285
如果您需要使用 GSSAPI,请尝试在容器中安装“gss-ntlmssp”。
或者,如果您的服务器接受其他身份验证类型,请使用另一种身份验证类型,例如 NTLM:
var cred = new NetworkCredential(user, password, domain);
var cache = new CredentialCache();
cache.Add(host, 25, "NTLM", cred);
client.Credentials = cache;
推荐阅读
- docker - docker 容器上的 tcpdump 给出错误“无效的输出文件数”
- r - 测量文本质量以进行清洗后的文本分析
- javascript - 当孩子展开时,嵌套的可折叠不能正确显示其内容
- java - 测试时有没有办法在 Spring 中获取 Controller 的“基本 URL”?
- r - 以迭代方式在数据框中创建多个新列
- java - 如何在没有用户输入的情况下在我的队列系统上添加自动 ID 号,必要性?
- javascript - requestAnimationFrame 与 setinterval 的游戏时钟?
- python - 字符串转换 python
- opengl - 存储缓冲区和错误对齐的数据
- angular - 从面向 HttpErrorResponse 的 Angular 中的 API 获取视频