rails smtp.UseDefaultCredentials 中以下的可用版本是什么

What is the available version of following in rails smtp.UseDefaultCredentials

我在 java 文件中有以下配置。我正在尝试转换为 RAILS

中的等效配置

如何转换 RAILS SMTP 配置

谢谢

Rails 中没有 SmtpClient.UseDefaultCredentials 功能的等效项。如果我理解 the docs correctly, this property makes the SMTP client send the username and password of the user currently logged into the system. This is only applicable when NTLM, negotiate or Kerberos-based authentication is used in the system (as documented here) 并且所有这些仅与 .NET 和 Windows 相关。 Windows 服务器将当前登录用户的凭据保存在凭据缓存中,并可以提供它们,例如发送电子邮件时。

Rails 环境中没有类似的东西。通常,Rails 应用程序有自己的用于发送邮件的单一凭据,在设置中配置(请参阅 Rails Guides 了解更多信息)。

如果每个登录到应用程序的用户确实需要单独的凭据,则必须将凭据保存在某个地方(例如数据库),这样您就可以在发送电子邮件时获得明文密码。这当然 有很多安全后果 ,通常很难安全地完成,因此不是首选方法(您可能必须以某种方式使用每个用户密钥加密凭据,但是我不确定最好的方法)。

添加@BoraMa 答案,默认情况下如果我们不提供任何与身份验证相关的密钥,则默认发送登录用户详细信息,类似于功能

SmtpClient.UseDefaultCredentials

config.action_mailer.smtp_settings = {
address:              'xx.xxx.x.xxx',
port:                 25,
ssl:                  false,
enable_starttls_auto: false  }

以上配置对我有用,我可以发送电子邮件。

谢谢