0

我一直在关注本教程,并且已经在 heroku 上进行了部署。联系表格完美运行,并且没有显示错误消息。当我使用注册按钮时,成功消息出现,没有错误消息。在 mailchimp 上登录显示该电子邮件确实已添加到列表中。

但是,我没有收到任何确认电子邮件(等待 24 小时并使用 2 封单独的电子邮件注册),无论是所有者电子邮件还是注册电子邮件。我已经检查了“设置/列表名称和默认活动/发送最终欢迎电子邮件”框以及创建表单部分的“发送最终欢迎电子邮件”框。

我相信问题出在我的 mailchimp 设置上,但我不确定。我也不确定我们是否打算使用“选择加入电子邮件”或如何激活它。我是 mailchimp 的新手,整个注册表单系统让我感到困惑。请帮忙。

编辑:按要求包含的文件:

配置/环境/development.rb

    Rails.application.configure do
      # Settings specified here will take precedence over those in config/application.rb.

      # In the development environment your application's code is reloaded on
      # every request. This slows down response time but is perfect for development
      # since you don't have to restart the web server when you make code changes.
      config.cache_classes = false

      # Do not eager load code on boot.
      config.eager_load = false

      # Show full error reports and disable caching.
      config.consider_all_requests_local       = true
      config.action_controller.perform_caching = false

      # Don't care if the mailer can't send.
      config.action_mailer.raise_delivery_errors = false

      # Print deprecation notices to the Rails logger.
      config.active_support.deprecation = :log

      # Raise an error on page load if there are pending migrations.
      config.active_record.migration_error = :page_load

      # Debug mode disables concatenation and preprocessing of assets.
      # This option may cause significant delays in view rendering with a large
      # number of complex assets.
      config.assets.debug = true

      config.action_mailer.smtp_settings = {
        address: "smtp.gmail.com",
        port: 587,
        domain: Rails.application.secrets.domain_name,
        authentications: "plain",
        enable_starttls_auto: true,
        user_name: Rails.application.secrets.email_provider_username,
        password: Rails.application.secrets.email_provider_password
      }
      # ActionMailer Config
      config.action_mailer.default_url_options = { :host => 'localhost:3000' }
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.raise_delivery_errors = true
      # Send email in development mode?
      config.action_mailer.perform_deliveries = true

      # Asset digests allow you to set far-future HTTP expiration dates on all assets,
      # yet still be able to expire them through the digest params.
      config.assets.digest = true

      # Adds additional error checking when serving assets at runtime.
      # Checks for improperly declared sprockets dependencies.
      # Raises helpful error messages.
      config.assets.raise_runtime_errors = true

      # Raises error for missing translations
      # config.action_view.raise_on_missing_translations = true
    end
4

1 回答 1

0

好吧,我解决了将状态从“订阅”更改为“待处理”的问题,显然 mailchimp 在使用单一选择加入时不会发送最终的欢迎电子邮件。这会发送一封请求确认的电子邮件,一旦确认,它就会发送最终的欢迎电子邮件并通知业主。我不认为这是书中的方法,如果有人以另一种方式解决了这个问题,请告诉我。

    def subscribe
      mailchimp = Gibbon::Request.new(api_key: Rails.application.secrets.mailchimp_api_key)
      list_id = Rails.application.secrets.mailchimp_list_id
      result = mailchimp.lists(list_id).members.create(
        body: {
          email_address: self.email,
          status: 'pending'
      })
      Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
    end
于 2015-11-02T03:52:55.383 回答