Sending emails with SideKiq fails (Job exception: :arguments expected to be an Array of individual string args )

I have setup Discourse 2.7.12 and configured it to send emails via Mailgun.

Even though the application is able to send test emails via the Administration panel, all the relevant email jobs fail at Sidekiq

Any ideas what could be the error?

Sidekiq example of error:

“email_token”=>“ca2fd58bd00511d21d04ca05da6239ad”, “current_site_id”=>“default”

Jobs::HandledExceptionWrapper: Wrapped ArgumentError: :arguments expected to be an Array of individual string args

Stack trace information

In the /logs i can see an error with title:

Job exception: :arguments expected to be an Array of individual string args

and stack trace:

/opt/bitnami/discourse/vendor/bundle/ruby/2.7.0/bundler/gems/mail-5b700fc95ee6/lib/mail/network/delivery_methods/sendmail.rb:53:in `initialize' /opt/bitnami/discourse/vendor/bundle/ruby/2.7.0/bundler/gems/mail-5b700fc95ee6/lib/mail/message.rb:278:in ` new’
/opt/bitnami/discourse/vendor/bundle/ruby/2.7.0/bundler/gems/mail-5b700fc95ee6/lib/mail/message.rb:278:in `delivery_method' actionmailer- ` wrap_delivery_behavior’
actionmailer- `wrap_delivery_behavior!' actionmailer- ` mail’
/opt/bitnami/discourse/lib/email/build_email_helper.rb:8:in `build_email' /opt/bitnami/discourse/app/mailers/download_backup_mailer.rb:7:in ` send_email’
actionpack- `process_action' actionpack- ` block in process_action’
activesupport- `run_callbacks' actionpack- ` process_action’
actionpack- `process' actionmailer- ` block in process’
actionmailer- `handle_exceptions' actionmailer- ` process’
actionview- `process' actionmailer- ` block in process’
activesupport- `block in instrument' activesupport- ` instrument’
activesupport- `instrument' actionmailer- ` process’
actionmailer- `block in processed_mailer' actionmailer- ` tap’
actionmailer- `processed_mailer' actionmailer- ` **getobj** ’
/opt/bitnami/ruby/lib/ruby/2.7.0/delegate.rb:80:in `method_missing' /opt/bitnami/discourse/lib/email/sender.rb:44:in ` send’
/opt/bitnami/discourse/app/jobs/regular/download_backup_email.rb:21:in `execute' /opt/bitnami/discourse/app/jobs/base.rb:232:in ` block (2 levels) in perform’
rails_multisite-4.0.0/lib/rails_multisite/connection_management.rb:80:in `with_connection' /opt/bitnami/discourse/app/jobs/base.rb:221:in ` block in perform’
/opt/bitnami/discourse/app/jobs/base.rb:217:in `each' /opt/bitnami/discourse/app/jobs/base.rb:217:in ` perform’
sidekiq-6.2.1/lib/sidekiq/processor.rb:196:in `execute_job' sidekiq-6.2.1/lib/sidekiq/processor.rb:164:in ` block (2 levels) in process’
sidekiq-6.2.1/lib/sidekiq/middleware/chain.rb:138:in `block in invoke' /opt/bitnami/discourse/lib/sidekiq/pausable.rb:138:in ` call’
sidekiq-6.2.1/lib/sidekiq/middleware/chain.rb:140:in `block in invoke' sidekiq-6.2.1/lib/sidekiq/middleware/chain.rb:143:in ` invoke’
sidekiq-6.2.1/lib/sidekiq/processor.rb:163:in `block in process' sidekiq-6.2.1/lib/sidekiq/processor.rb:136:in ` block (6 levels) in dispatch’
sidekiq-6.2.1/lib/sidekiq/job_retry.rb:112:in `local' sidekiq-6.2.1/lib/sidekiq/processor.rb:135:in ` block (5 levels) in dispatch’
sidekiq-6.2.1/lib/sidekiq/rails.rb:14:in `block in call' activesupport- ` wrap’
activesupport- `block in wrap' activesupport- ` wrap’
activesupport- `wrap' sidekiq-6.2.1/lib/sidekiq/rails.rb:13:in ` call’
sidekiq-6.2.1/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch' sidekiq-6.2.1/lib/sidekiq/processor.rb:257:in ` stats’
sidekiq-6.2.1/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch' sidekiq-6.2.1/lib/sidekiq/job_logger.rb:13:in ` call’
sidekiq-6.2.1/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch' sidekiq-6.2.1/lib/sidekiq/job_retry.rb:79:in ` global’
sidekiq-6.2.1/lib/sidekiq/processor.rb:124:in `block in dispatch' sidekiq-6.2.1/lib/sidekiq/logger.rb:11:in ` with’
sidekiq-6.2.1/lib/sidekiq/job_logger.rb:33:in `prepare' sidekiq-6.2.1/lib/sidekiq/processor.rb:123:in ` dispatch’
sidekiq-6.2.1/lib/sidekiq/processor.rb:162:in `process' sidekiq-6.2.1/lib/sidekiq/processor.rb:78:in ` process_one’
sidekiq-6.2.1/lib/sidekiq/processor.rb:68:in `run' sidekiq-6.2.1/lib/sidekiq/util.rb:43:in ` watchdog’
sidekiq-6.2.1/lib/sidekiq/util.rb:52:in `block in safe_thread’

Relevant code (mail/network/delivery_methods/sendmail.rb)

#   Mail.defaults do
  #     delivery_method :sendmail, :location => '/absolute/path/to/your/sendmail'
  #   end
  # Then just deliver the email as normal:
  #   Mail.deliver do
  #     to ''
  #     from ''
  #     subject 'testing sendmail'
  #     body 'testing sendmail'
  #   end
  # Or by calling deliver on a Mail message
  #   mail = do
  #     to ''
  #     from ''
  #     subject 'testing sendmail'
  #     body 'testing sendmail'
  #   end
  #   mail.deliver!
  class Sendmail
    DEFAULTS = {
      :location   => '/usr/sbin/sendmail',
      :arguments  => %w[ -i ]

    attr_accessor :settings

    class DeliveryError < StandardError

    def initialize(values)

      self.settings = self.class::DEFAULTS.merge(values)
      raise ArgumentError, ":arguments expected to be an Array of individual string args" if settings[:arguments].is_a?(String)

It’s the initialize method that raises the exception

I fixed it by setting the SMTP parameters to the Sidekiq as well

In /opt/bitnami/scripts/

these are exported


But Sidekiq was expecting the parameters not to have the DISCOURSE_ prefix.
So adding the following fixed the problem:

export SMTP_HOST=“xxx”
export SMTP_ADDRESS=“xx”
export SMTP_PORT_NUMBER=“587”
export SMTP_USER=“xxx”
export SMTP_USER_NAME=“xxx”
export SMTP_PASSWORD=“xxx”

I am getting this error while sending test email. I tried adding smtp details in sidekiq. Note: I have deployed this on k8s. I am on version 3.0.6