使用Sidekiq和Mailer发送异步电子邮件[RAILS]

时间:2014-07-16 04:05:01

标签: ruby-on-rails sidekiq mailer

所以我目前正在尝试使用Rails gem'sidekiq'异步发送大量电子邮件,因此不会使下一页的加载时间陷入停滞。

我所做的一切除外:

FeedbackMailer.invite_contact(current_user, current_business, contact).deliver()

这是我自己的邮件程序和一组必须用来为客户端创建电子邮件的参数。

sidekiq抛出的错误是:

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

default_url_options [:host]在application.rb中设置,但似乎没有在此处阅读。我也尝试设置only_path:true并仍然得到相同的错误。

当我在sidekiq的工作人员之外时,我可以发送电子邮件,问题只存在于那里。有人知道解决方法,以便可以从sidekiq的工作人员发送电子邮件吗?

在回答之前,使用Mailer.delay并不能解决我的问题,因为邮件周围有很多其他代码必须在循环的每次迭代过程中消失。

1 个答案:

答案 0 :(得分:0)

如果未正确配置邮件,则会发生此错误。检查相关环境文件(production.rb或staging.rb)中是否包含此类内容

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address =>              'smtp.something.com',
  :port =>                  587,
  :domain =>               'yourdomain.com',
  :user_name =>            'account-admin@yourdomain.com',
  :password =>             'your secure password',
  :authentication =>       'plain',
  :enable_starttls_auto => true
}