【问题标题】:Failed to send email in Heroku在 Heroku 中发送电子邮件失败
【发布时间】:2019-07-19 12:33:27
【问题描述】:

我收到这个错误

getaddrinfo: Servname not supported for ai_socktype

在用户注册后发送确认电子邮件时在 heroku 中。

我使用弹性电子邮件作为 smtp,但在 heroku 中找不到任何插件。我需要一个插件来发送电子邮件吗?

【问题讨论】:

    标签: ruby-on-rails email heroku devise


    【解决方案1】:

    错误是由于将 smtp_port 解析为字符串。将 smtp_port 类型转换为整数将解决此问题。令人惊讶的是,我只能在 heroku 中复制错误。

      # smtp mail setup
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.default_url_options = { host: 'abc.herokuapp.com' }
      config.action_mailer.smtp_settings = {
        address:              ENV['SMTP_ADDRESS'],
        port:                 ENV['SMTP_PORT'].to_i,
        domain:               ENV['SMTP_DOMAIN'],
        user_name:            ENV['SMTP_USER_NAME'],
        password:             ENV['SMTP_PASSWORD'],
        authentication:       'plain',
        enable_starttls_auto: true
      }
     config.action_mailer.perform_deliveries = true
     config.action_mailer.raise_delivery_errors = true
     config.action_mailer.default_options = { from: 'contact@abc.com' }
    

    【讨论】:

      猜你喜欢
      • 2017-12-08
      • 1970-01-01
      • 2014-08-29
      • 2017-02-09
      • 2016-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多