Last active
February 9, 2021 11:18
-
-
Save ahmad19/829cba9311aadea5124ab3b101239a79 to your computer and use it in GitHub Desktop.
Steps to allow email sending on heroku through sidekiq.
This file contains hidden or 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
# Create Procfile which is required by heroku. | |
web: bin/rails server -p $PORT | |
worker: bundle exec sidekiq -c 2 -e staging | |
# REDIS | |
# REDISTOGO_URL for local is bydefault: redis://0.0.0.0:6379/0 | |
# REDISTOGO_URL for heroku | |
# Use Redistogo heroku addon | |
# Addon will provide REDISTOGO_URL which should be added in the heroku config. | |
# config/initializers/sidekiq.rb | |
Sidekiq.configure_server do |config| | |
config.redis = { url: ENV["REDISTOGO_URL"], id: nil } | |
end | |
Sidekiq.configure_client do |config| | |
config.redis = { url: ENV["REDISTOGO_URL"], id: nil } | |
end | |
# smtp settings: | |
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmail | |
# make sure domain name does not contain https. | |
config.action_mailer.smtp_settings = { | |
address: 'smtp.gmail.com', | |
port: 587, | |
domain: ENV['DOMAIN'], | |
user_name: ENV['GMAIL_USERNAME'], | |
password: ENV['GMAIL_PASSWORD'], | |
authentication: 'plain', | |
enable_starttls_auto: true } | |
config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] } | |
# And since we are using gmail therefore google blocks the application to connect with gmail. Therefore we need to allow that connection. | |
# Reference is here - https://stackoverflow.com/a/20262500/1468122 | |
# Sidekiq docs from wiki | |
# Heroku - https://github.com/mperham/sidekiq/wiki/Heroku | |
# Redis - https://github.com/mperham/sidekiq/wiki/Using-Redis#multiple-redis-instances |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment