ruby on rails 4.2 - Mailer method not being called? -
inside controller:
def update @user.update({approved: true}) usermailer.send_approved_mail(@user) redirect_to(root_url) end
inside user_mailer.rb
class usermailer < devise::mailer def send_approved_mail(user) @resource = user email_body = render "user_activated_mail" if @resource.valid? client = postmark::apiclient.new(env["postmark_api_key"]) client.deliver(from: env["postmark_signature"], to: @resource.email, subject: "user activation information.", tag: 'account-activated', :content_type => "text/html", html_body: email_body) end end end
in rails 4.1.0 above method in controller being called , email being sent, in rails 4.2 mailer method in controller not being called, when called rails console works. have made necessary configuration postmark api , in configuration files. thing in rails 4.1.0 mailer inside controller gets called in rails 4.2 doesn't works when called rails console. exact reason can't figure out.
the behavior notice here new default introduced in rails 4.2:
with introduction of active job , #deliver_later ... invocation of instance methods (on mailer) deferred until either deliver_now or deliver_later called.
check out rails 4.2 upgrade guide more details.
don’t worry though. can still use postmark actionmailer. official postmark rails gem provides drop-in integration actionmailer postmark. using should able write mailers if regular rails mailers without need manually manage postmark connections in code.
p.s. work @ wildbit (creators of postmark). feel free contact directly @ time.
Comments
Post a Comment