heroku-18 support will end soon(ended?), needed to update to latest
The big problem is it only supports Ruby 3.1. However, our system was working on Ruby 2.7 and Rails 5. To updating Ruby version(2.7 -> 3.1), also needed to update rails gem(5.2 -> 6.1). Then also required to add the following gems in Gemfile.
gem 'net-imap', '~> 0.2' gem 'net-pop', '~> 0.1' gem 'net-smtp', '~> 0.3'
In addition(if you are using activerecord), may need to update database tables related to activerecord.
rails active_storage:update rails db:migrate