- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个非常基本的邮件设置如下发送交易邮件:
class PayoutMailer < ApplicationMailer
default from: 'hello@groundworkai.com'
def payout_success_email(email, payment_size, user_name)
@payment_size = payment_size
@user_name = user_name
subject = 'Your Rewards Have Been Sent!'
mail(to: email, from: 'hello@myservice.com', subject: subject)
end
end
我正在用这一行测试:
PayoutMailer.payout_success_email('test@example.com',
200000,
'test name').deliver_later
我的问题是,当我使用 .deliver 或 .deliver_now 时,邮件会发送,但是当我使用 Deliver_later 异步委派它时,它会排队但从不发送。输出是:
I, [2018-01-20T15:27:44.140104 #4] INFO -- : [ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 265cb31a-dec4-4adb-866d-06e44645c53a) to Async(mailers) with arguments: "PayoutMailer", "payout_success_email", "deliver_now", "test@example.com", 200000, "test name"
我知道 ActionJob 在我使用 Deliver_later 时正在处理它,根据 docs :
Active Job's default behavior is to execute jobs via the :async adapter. So, you can use deliver_later now to send emails asynchronously. Active Job's default adapter runs jobs with an in-process thread pool. It's well-suited for the development/test environments, since it doesn't require any external infrastructure, but it's a poor fit for production since it drops pending jobs on restart. If you need a persistent backend, you will need to use an Active Job adapter that has a persistent backend (Sidekiq, Resque, etc).
此时,我不需要持久后端,使用进程内线程池就可以了。有没有什么方法可以让我在不引入 Sidekiq + Redis 的外部基础设施的情况下使用 Deliver_later?
最佳答案
异步适配器无法通过 rake 任务工作。
尝试内联,或使用 Deliver_now
从 http://edgeguides.rubyonrails.org/active_job_basics.html#job-execution
Using the asynchronous queue from a Rake task (for example, to send an email using .deliver_later) will generally not work because Rake will likely end, causing the in-process thread pool to be deleted, before any/all of the .deliver_later emails are processed. To avoid this problem, use .deliver_now or run a persistent queue in development.
关于ruby-on-rails - rails 5 : ActionMailer's "deliver_later" never delivers in production,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48364051/
您可以通过添加 :queue 作为可选参数来指定在 ActionMailer 中调用 Deliver_later 时要使用的队列,例如: Notifier.welcome(User.first.id)
环境 Ruby 2.2.1、Rails 4.2.0、rspec-core 3.2.2、rspec-expectations 3.2.0、rspec-mocks 3.2.1、rspec-rails 3.
我正在使用 ActionMailer 发送电子邮件,这些电子邮件包含图像。包含我正在使用的图像 和 config.action_controller.asset_host在暂存/生产中设置正确。 这些
错误 我已经完成了 ActionMailer 设置并在开发中完美运行。我可以调用 UserMailer.welcome(user).deliver,然后电子邮件就会到达目的地。但是,当我将代码投入生产
我正在尝试向我们的用户发送一封本质上只是一张巨型图像的 HTML 电子邮件。到目前为止,我还没有尝试过任何花哨的东西。我的 View 如下所示: body {
一段时间以来,我一直在苦苦思索。我有这个字符串: [18] pry(main)> p.title => "Human meat – Wesker and Son butchers at Smithfi
我正在尝试在我的开发环境中设置一个简单的 contact_us 页面,用户可以在其中使用我创建的表单发送查询。我已经设置了 ActiveMailer 和联系人模型/ Controller / View
我的 config/environments/development.rb 中有以下内容 # ActionMailer settings config.action_mailer.perfor
有没有简单的方法来做 response.should render_template(:foo) 的等价物?在邮件规范中?这是我想要做的: mail.should render_template(:w
我已将 Capistrano 设置为在部署我的 RoR (2.3.8) 应用程序后发送电子邮件。我有一个 config/cap_mailer.rb文件基本上如下所示: ActionMailer::Ba
我有一个问题,ActionMailer 有时不发送电子邮件。它是可重复的,并且会在某些时候影响某些人,尽管导致它的原因是个谜。 尽管 config.action_mailer.raise_delive
我正在使用 ActionMailer 并且在我的邮件模型中,我有一个这样的 from set default :from => "from@example.org" 在我的 environment.r
我不知道为什么,但是 Rails Mailer 使用 Gmail 帐户发送的电子邮件收到的邮件带有主题但正文为空... postman : class ContatoMailer E
我有以下代码。它是一个 ActionMailer 类方法,发送包含两种附件的电子邮件: pdf 文件 (_attachment),在内存中呈现并直接添加到消息中 一些其他文件 (_attached_f
通过actionmailer发送邮件时,在SMTP服务器正常或错误时,该 Action 邮件将从SMTP服务器获得响应。有没有办法在发送邮件后检索此响应? 另外,如果SMTP服务器未抛出任何错误,该怎
我的 Rails 3.1 项目中的 ActionMailer 有一个奇怪的行为,ActionMailer::Base.deliveries 在测试中是空的,而我实际上可以通过在 rails 控制台中运
我一直在使用 actionmailer,但我总觉得它很笨重而且不直观。 你们知道其他更轻便、更直观的解决方案吗? 最佳答案 看看 Pony gem(如 Pony Express),它是 ActionM
我需要在Rails应用程序中使用两个不同的smtp服务器。看来ActionMailer的构造方式,不可能有不同的smtp_settings用于 一个子类。每当发送邮件时,我都可以重新加载每个邮件程序类
看起来很简单,但我还没能让它发挥作用。这些文件在 Web 应用程序上的 S3 上工作正常,但当我通过下面的代码通过电子邮件发送它们时,文件已损坏。 应用程序堆栈:rails 3、heroku、回形针
我在 app/models 中有以下邮件代码。 class Mailman "xyz" # Sends an Email reminder to all the users who missed
我是一名优秀的程序员,十分优秀!