gpt4 book ai didi

ruby-on-rails - Rails3 Beta4 Devise Delayed_job配置

转载 作者:行者123 更新时间:2023-12-04 18:25:10 24 4
gpt4 key购买 nike

我想使用delay_job在后端发送电子邮件,这是
/config/initializers/setup_mail.rb

ActionMailer::Base.smtp_settings = {  
:address => "smtp.gmail.com",
:port => 587,
:domain => DOMAIN,
:user_name => USERNAME,
:password => PASSWORD,
:authentication => "plain",
:enable_starttls_auto => true
}


所以我想知道如何配置delay_job在后端发送邮件。谢谢。

最佳答案

您应该先使用Action Mailer教程http://edgeguides.rubyonrails.org/action_mailer_basics.html,然后将您的邮件标记为在delay_job中执行:

class UserMailer < ActionMailer::Base
default :from => "notifications@example.com"

def welcome_email(user)
@user = user
@url = "http://example.com/login"
mail(:to => user.email,
:subject => "Welcome to My Awesome Site")
end

handle_asynchronously :welcome_email
end


您还可以在config中异步调用handle:

UserMailer.handle_asynchronously :welcome_email

关于ruby-on-rails - Rails3 Beta4 Devise Delayed_job配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3174533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com