Delayed Jobs with Action Mailer using Mailjet API on a Heroku Rails App -
looking send delayed jobs mailer mailjet's api, emails not being sent. works locally foreman, again, on development on heroku not sending. delayed jobs table created.
here's gemfile
gem 'mailjet' gem 'delayed_job_active_record'
the controller
def create @article = article.new(article_params) if @article.save # send email referral email all_users = user.all all_users.each |user| articlemailer.delay.article_confirmation(user,@article) end redirect_to @article else render 'new' end end
the mailer
class articlemailer < actionmailer::base def article_confirmation(user,article) @user = user @article = article mailjet::messagedelivery.create( to: user.email, from: "[email]@gmail", subject: "[html]", html: "[html] end end
the /environments/development.rb file
config.action_mailer.delivery_method = :mailjet config.action_mailer.smtp_settings = { address: "in-v3.mailjet.com", port: 587, domain: "[ourdomain].com", authentication: "login", enable_starttls_auto: true, user_name: "[our_username]", password: "[our_password]", require_ssl: true }
the schema
create_table "delayed_jobs", force: true |t| t.integer "priority", default: 0, null: false t.integer "attempts", default: 0, null: false t.text "handler", null: false t.text "last_error" t.datetime "run_at" t.datetime "locked_at" t.datetime "failed_at" t.string "locked_by" t.string "queue" t.datetime "created_at" t.datetime "updated_at" end add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree create_table "friendly_id_slugs", force: true |t| t.string "slug", null: false t.integer "sluggable_id", null: false t.string "sluggable_type", limit: 50 t.string "scope" t.datetime "created_at" end
update:
when run delayed::job.last
=> #<delayed::backend::activerecord::job id: 181, priority: 0, attempts: 0, handler: "--- !ruby/object:delayed::performablemailer\nobject...", last_error: nil, run_at: "2014-12-01 19:04:25", locked_at: nil, failed_at: nil, locked_by: nil, queue: nil, created_at: "2014-12-01 19:04:25", updated_at: "2014-12-01 19:04:25">
Comments
Post a Comment