在Rails中发送延迟电子邮件?

时间:2011-02-21 11:55:19

标签: ruby-on-rails email queue gem delayed-job

我正在使用delayed_job来延迟从我的应用程序向FreeagentCentral(会计软件包)发送信息。同时,它还使用PostmarkApp的gem发送了两封电子邮件。

# POST /kases
# POST /kases.xml
def create
@company = Company.find(params[:kase][:company_id])
@kase = @company.kases.create!(params[:kase])

respond_to do |format|
UserMailer.delay.deliver_makeakase("email@address.com", "Highrise", @kase) if    params[:sendtohighrise]
UserMailer.delay.deliver_makeakaseteam("email2@address.com", "Highrise", @kase) if params[:notify_team_of_creation]
@kase.delay.create_freeagent_project(current_user) if params[:send_to_freeagent]

#flash[:notice] = 'Case was successfully created.'
flash[:notice] = fading_flash_message("Case was successfully created.", 5)

format.html { redirect_to(@kase) }
format.xml  { render :xml => @kase, :status => :created, :location => @kase }
end
end

以上代码不会产生任何错误 - 但电子邮件不会被发送。我想知道我做错了什么?

应该是这样,还是我错过了什么:

UserMailer.delay.deliver_makeakaseteam("email2@address.com", "Highrise", @kase) if params[:notify_team_of_creation]

谢谢,

丹尼

更新

--- 
- !ruby/object:Delayed::Backend::ActiveRecord::Job 
  attributes: 
    created_at: 2011-02-21 13:30:38
    locked_by: 
    failed_at: 
    updated_at: 2011-02-21 13:30:38
    handler: |
      --- !ruby/struct:Delayed::PerformableMethod 
      object: LOAD;UserMailer
      method: :deliver_makeakase
      args: 
      - email@email.com
      - Highrise
      - LOAD;Kase;19

    priority: "0"
    id: "1"
    run_at: 2011-02-21 13:30:38
    locked_at: 
    attempts: "0"
    last_error: 
  attributes_cache: {}

- !ruby/object:Delayed::Backend::ActiveRecord::Job 
  attributes: 
    created_at: 2011-02-21 13:30:38
    locked_by: 
    failed_at: 
    updated_at: 2011-02-21 13:30:38
    handler: |
      --- !ruby/struct:Delayed::PerformableMethod 
      object: LOAD;UserMailer
      method: :deliver_makeakaseteam
      args: 
      - email@email.com
      - Highrise
      - LOAD;Kase;19

    priority: "0"
    id: "2"
    run_at: 2011-02-21 13:30:38
    locked_at: 
    attempts: "0"
    last_error: 
  attributes_cache: {}

=> nil

0 个答案:

没有答案