We've moved discussions to Discord

Another Email Question

Administrator Developer
I am now trying to set up sendgrid to test in my development environment and am getting this error:

  (2.5ms)  COMMIT
19:57:18 web.1     | Devise::Mailer#reset_password_instructions: processed outbound mail in 1.6ms
19:57:18 web.1     | Completed 500 Internal Server Error in 201ms (ActiveRecord: 6.4ms | Allocations: 9960)
19:57:18 web.1     |
19:57:18 web.1     |
19:57:18 web.1     |
19:57:18 web.1     | RuntimeError (Invalid delivery method :sendgrid):

I have set up in my credentials the correct api key etc.

in my enviroment:

# Set the default URL for ActionMailer in development.
  config.action_mailer.default_url_options = { url: 'https://app.sendgrid.com/settings/api_keys'}
  config.action_mailer.delivery_method = :sendgrid

Can't for the life of me figure it out :)

-Andrew Galewsky


Chris Oliver
You can have Jumpstart configure the development env emails for you the same as production.

Just drop this into config/environments/development.rb at the end.

ActionMailer::Base.default_options     = { from: Jumpstart.config.default_from_email }
ActionMailer::Base.default_url_options = { host: Jumpstart.config.domain }
ActionMailer::Base.smtp_settings       = Jumpstart::Mailer.new(Jumpstart.config).settings

It always configures SMTP as the delivery method so that all the different email providers can be kept somewhat consistent. 
Shaunak Vairagare
Chris Oliver  

Copying these settings to development.rb is throwing an error on booting rails server: 

Also, the jumpstart configuration UI says the mail settings will only be enabled for production. Does that mean it wont enable it for staging environment?


➔ overmind s
system  | Tmux socket name: overmind-eyesol-IKuEuAQ3omLzuvO1BDi8_T
system  | Tmux session ID: eyesol
system  | Listening at ./.overmind.sock
webpack | Started with pid 3434...
web     | Started with pid 3433...
webpack | ℹ 「wds」: Project is running at http://localhost:3035/
webpack | ℹ 「wds」: webpack output is served from /packs/
webpack | ℹ 「wds」: Content not from webpack is served from /Users/shaunak/code/eyesol/public/packs
webpack | ℹ 「wds」: 404s will fallback to /index.html
web     | => Booting Puma
web     | => Rails 6.0.2.2 application starting in development
web     | => Run `rails server --help` for more startup options
web     | Exiting
web     | Traceback (most recent call last):
web     | 	85: from bin/rails:3:in `<main>'
web     | 	84: from bin/rails:3:in `load'
web     | 	83: from /Users/shaunak/code/eyesol/bin/spring:15:in `<top (required)>'
web     | 	82: from /Users/shaunak/code/eyesol/bin/spring:15:in `require'
web     | 	81: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
web     | 	80: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
web     | 	79: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
web     | 	78: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
web     | 	77: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
web     | 	76: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
web     | 	75: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
web     | 	74: from /Users/shaunak/code/eyesol/bin/rails:9:in `<top (required)>'
web     | 	73: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
web     | 	72: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
web     | 	71: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
web     | 	70: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
web     | 	69: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
web     | 	68: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
web     | 	67: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
web     | 	66: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
web     | 	65: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands.rb:18:in `<main>'
web     | 	64: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/command.rb:46:in `invoke'
web     | 	63: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/command/base.rb:69:in `perform'
web     | 	62: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
web     | 	61: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
web     | 	60: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
web     | 	59: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `perform'
web     | 	58: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `tap'
web     | 	57: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
web     | 	56: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:37:in `start'
web     | 	55: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:77:in `log_to_stdout'
web     | 	54: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/server.rb:422:in `wrapped_app'
web     | 	53: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/server.rb:249:in `app'
web     | 	52: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/server.rb:349:in `build_app_and_options_from_config'
web     | 	51: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/builder.rb:66:in `parse_file'
web     | 	50: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/builder.rb:105:in `load_file'
web     | 	49: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/builder.rb:116:in `new_from_string'
web     | 	48: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/rack-2.2.2/lib/rack/builder.rb:116:in `eval'
web     | 	47: from config.ru:3:in `block in <main>'
web     | 	46: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative'
web     | 	45: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
web     | 	44: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
web     | 	43: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
web     | 	42: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
web     | 	41: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
web     | 	40: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
web     | 	39: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
web     | 	38: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
web     | 	37: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
web     | 	36: from /Users/shaunak/code/eyesol/config/environment.rb:5:in `<main>'
web     | 	35: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/application.rb:363:in `initialize!'
web     | 	34: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
web     | 	33: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
web     | 	32: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
web     | 	31: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
web     | 	30: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `call'
web     | 	29: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each'
web     | 	28: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
web     | 	27: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:415:in `each_strongly_connected_component_from'
web     | 	26: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:415:in `call'
web     | 	25: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:50:in `tsort_each_child'
web     | 	24: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:50:in `each'
web     | 	23: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
web     | 	22: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
web     | 	21: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
web     | 	20: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
web     | 	19: from /Users/shaunak/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
web     | 	18: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
web     | 	17: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `run'
web     | 	16: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
web     | 	15: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/engine.rb:611:in `block in <class:Engine>'
web     | 	14: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/engine.rb:611:in `each'
web     | 	13: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
web     | 	12: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
web     | 	11: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
web     | 	10: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
web     | 	 9: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
web     | 	 8: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
web     | 	 7: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
web     | 	 6: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
web     | 	 5: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
web     | 	 4: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
web     | 	 3: from /Users/shaunak/code/eyesol/config/environments/development.rb:1:in `<main>'
web     | 	 2: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/railtie.rb:216:in `configure'
web     | 	 1: from /Users/shaunak/.rvm/gems/ruby-2.6.6@eyesol/gems/railties-6.0.2.2/lib/rails/railtie.rb:216:in `instance_eval'
web     | /Users/shaunak/code/eyesol/config/environments/development.rb:76:in `block in <main>': undefined method `default_from_email' for {}:Hash (NoMethodError)
web     | Did you mean?  default_proc
web     | Exited
webpack | Interrupting...
webpack | Exited
Shaunak Vairagare
Chris Oliver update: it seems I can't use  Jumpstart.config in the development.rb as it is empty when the development.rb or staging.rb is loaded.  So how do I setup emails in dev and staging env?
Chris Oliver
Shaunak Vairagare The example code is just what we do in Production, so copying this to another environment will work the exact same.

https://gitlab.com/gorails/jumpstart-pro/-/blob/master/lib/jumpstart/lib/jumpstart/engine.rb#L29-33

You should be able to add that to your dev environment and it'll work just fine.
Shaunak Vairagare
Will I need to comment out the following options in the development.rb or would those stay? I don't see those in production.eb

config.action_mailer.default_url_options = {host: "localhost", port: 3000}
config.action_mailer.delivery_method = :sendgrid
Chris Oliver
We only configure production for you (as you can see on the first line I linked on GitLab).

Development is configured to use the Letter Opener gem so you can browse the emails without actually sending them.
Notifications
You’re not receiving notifications from this thread.