简体   繁体   English

在Rails中使用DelayedJob gem发送电子邮件

[英]Sending email using DelayedJob gem in Rails

There is the following code for sending email asynchronously: 有以下用于异步发送电子邮件的代码:

class OrderMailer < ActionMailer::Base
  default from: "some mail"

  def send_order_info(order) 
    @order = order
    mail(to: Settings.report_email, subject: "Some subject")
  end

  #handle_asynchronously :send_order_info
end

It code works, but if I remove comment from 'handle_asynchronously' line I can't send any email. 它的代码有效,但是如果我从“ handle_asynchronously”行中删除注释,则无法发送任何电子邮件。 What is the trouble? 有什么问题吗? How can I fix it? 我该如何解决? Thanks. 谢谢。

如果您想在后台发送电子邮件,请执行

 OrderMailer.delay.send_order_info(@order)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM