Forcing digest send for dev purposes

email

(Tom Bartlett) #1

I’ve been using rake enqueue_digest_emails and a user who hasn’t been seen for a while to test some digest email changes - is there a way to manually trigger the digest from within app? This is purely for dev testing, not to send to a live spam or similar.


(Arpit Jalan) #2

PROTIP: you can preview digest email from admin – http://discourse.example.com/admin/email/preview-digest


(Tom Bartlett) #3

Thanks @techAPJ , I’ve used that before, but the dev is to test deliverability of the digest emails, so I need to trigger actual sending of the emails. I am overriding the templates in a plugin (which is a bit of a faff to achieve - not like with the hbs templates which are a simple asset inclusion)

Currently, I’m doing this:

  1. Create a new topic (or 3)
  2. Run rake rake enqueue_digest_emails
  3. Give sidekiq a slap, hoping it will push them through
  4. Check /logs for any debug info

EDIT: This process does NOT appear to trigger a digest email.


(Erick Guan) #4

At the beginning of that rake task, it says desc "This task is called by the Heroku scheduler add-on". Apparently, it’s not for development.

Enter the rails console, Jobs::UserEmail.new.execute(user_id: -1, type: :digest) will give you something.

As of deliverability of the digest emails, what do you mean by that?


(Tom Bartlett) #5

Perfect - that line does exactly what I needed.

For clarity, this was my situation:

  • Trying to “brand” the email templates, by overriding them in a plugin
  • Had a bug which stopped digests being sent
  • Needed to trigger the digest manually to test the bug fix

“Deliverability” was probably a red-herring. I simply meant “I want to send the digest manually and see it in an inbox”.