-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle net-smtp mail dependency error for Ruby 3.1
In Ruby 3.1, net-stmp is not a default gem anymore. Mail uses it as dependency and try to loads without declaring the dependency, which will fail unless the application have net-stmp in the gemfile. For Rails 7 we could just make those gems dependencies of the framework. But in Rails 6.1, which we need to support old rubies, installing those gems can cause trouble. So instead we are intercepting the error and telling people to add the gem to the Gemfile.
- Loading branch information
1 parent
97064aa
commit 06ac69f
Showing
6 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
require "mail" | ||
require "action_mailbox/mail_with_error_handling" | ||
|
||
# The hope is to upstream most of these basic additions to the Mail gem's Mail object. But until then, here they lay! | ||
Dir["#{File.expand_path(File.dirname(__FILE__))}/mail_ext/*"].each { |path| require "action_mailbox/mail_ext/#{File.basename(path)}" } |
10 changes: 10 additions & 0 deletions
10
actionmailbox/lib/action_mailbox/mail_with_error_handling.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
begin | ||
require "mail" | ||
rescue LoadError => error | ||
if error.message.match?(/net-stmp/) | ||
$stderr.puts "You don't have net-stmp installed in your application. Please add it to your Gemfile and run bundle install" | ||
raise | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
actionmailer/lib/action_mailer/mail_with_error_handling.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
begin | ||
require "mail" | ||
rescue LoadError => error | ||
if error.message.match?(/net-stmp/) | ||
$stderr.puts "You don't have net-stmp installed in your application. Please add it to your Gemfile and run bundle install" | ||
raise | ||
end | ||
end |