Skip to content

Set a default from address #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ All exceptions are reported automatically. No additional code required.

Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.

## Optional configuration

Set a custom from address.

```ruby
# default: "[email protected]"
config.email_error_reporter.from = "[email protected]"
```

## Test your setup

You can use the built-in rake task `rake email_error_reporter:check` to check if everything works correctly in your setup.
Expand Down
1 change: 1 addition & 0 deletions lib/email_error_reporter/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Engine < ::Rails::Engine

config.email_error_reporter = ActiveSupport::OrderedOptions.new
config.email_error_reporter.to = []
config.email_error_reporter.from = "[email protected]"

initializer "email_error_reporter.error_subscribe" do
Rails.error.subscribe(Subscriber.new)
Expand Down
1 change: 1 addition & 0 deletions lib/email_error_reporter/error_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def error(error, handled:, severity:, context:, source: nil)

mail(
subject: "#{severity_to_emoji.fetch(@severity)} #{error.class}",
from: Rails.application.config.email_error_reporter.from,
to: Rails.application.config.email_error_reporter.to
)
end
Expand Down