0

As shown in code below, recipient's mails are hard-coded, how can I set them in environment variable

  Example::Application.config.middleware.use ExceptionNotification::Rack,
    :email => {
      email_prefix: "[Error] ",
      sender_address: %{"Exception Notifier" <exception@example.com>},
      exception_recipients: %w{example@example.com example2@example.com}
  }

I've tried exception_recipients: ENV['mail'] %w{ENV['mail']} "%w{#{ENV['mail']}}", but none works, it gives syntax error

Cœur
  • 37,241
  • 25
  • 195
  • 267
Raza
  • 2,320
  • 2
  • 22
  • 32

1 Answers1

1

Depends on the format you pass the mail variable in`. I'd probably go with semicolon separated list of email addresses.

ENV["mail"] # => "example@example.com;example2@example.com"

And then in the configuration:

exception_recipients: String(ENV["mail"]).split(";")

Notice the use of String to make sure it won't blow up on you if the key is not set (nil).

Jiří Pospíšil
  • 14,296
  • 2
  • 41
  • 52