【问题标题】:Net::SMTPAuthenticationError: 530-5.7.0 Authentication Required Rails Mailer using environmental variable on configNet::SMTPAuthenticationError: 530-5.7.0 Authentication Required Rails Mailer 在配置中使用环境变量
【发布时间】:2019-12-16 03:49:44
【问题描述】:

我正在使用 Rails Mailer 在我的应用程序上发送确认邮件,并且我已经设置了我的 config>environment>development.rb,如下所示:

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: 'smtp.gmail.com',
    # user_name: ENV["MAIL_USERNAME"],
    # password: ENV["MAIL_PASSWORD"],
    user_name: "myemail@mydomain.com",
    password: "myCorrectPassword",
    authentication: :login,
    enable_starttls_auto: true
  } 

问题

当我对"myemail@mydomain.com""myCorrectPassword"user_namepassword 进行硬编码时,邮件程序会发送一封电子邮件,并且工作正常。但是,当我使用 ENV 确保我的凭据安全时,我收到了 Net::SMTPAuthenticationError: 530-5.7.0 Authentication Required 错误。

在终端上,我检查了我的 ENV 以确保我为每个变量输入了正确的值,并且它们是正确的。

我还能尝试什么?

【问题讨论】:

    标签: ruby-on-rails environment-variables


    【解决方案1】:

    当你在 Rails 控制台 ENV["MAIL_USERNAME"] 中运行它时,你会得到什么? 你的 ~/.bash_profile 有这个

      export MAIL_USERNAME="myemail@mydomain.com"
    

    尝试一次源 ~/.bash_profile

    【讨论】:

    • 当我签入 bash 时,我得到了正确的值。我不确定是什么问题,但我使用 figaro gem 解决了它。
    猜你喜欢
    • 2023-01-29
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 2023-02-13
    • 2020-08-20
    • 1970-01-01
    • 2014-11-02
    • 2018-02-12
    相关资源
    最近更新 更多