Home>
I do not understand the email sending settings for DEVISE. I would be grateful if anyone came to know this.

Environment

ruby 2.5.1
rails 6.0.3.2
devise 4.7.2
mac catalina 10.15.5
https://localhost:9292/

If i press send me reset password from the devise forgot your password page

ArgumentError in Devise::Passwords#create
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true


And the err message appears.

So, register for sendgrid (English)
config>environments>development.rb
Add the following to

config.action_mailer.default_url_options = {host: ENV['SG_WEB_HOST'], protocol: ENV['SG_WEB_PROTOCOL']}
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :https
  config.action_mailer.https_settings = {
    :address =>ENV['SG_SMTP_ADDRESS'],
    :domain =>ENV['SG_DOMAIN'],
    :port =>ENV['SG_PORT'],
    :user_name =>ENV['SG_USER_NAME'],
    :password =>ENV['SENDGRID_API_KEY'],
    :authentication =>'login',
    :enable_starttls_auto =>true


Add the following to .zshrc
SENDGRID_API_KEY is private.
SG_SMTP_ADDRESS,SG_DOMAIN
Does not know what to write.

export SG_USER_NAME='apikkey'
export SENDGRID_API_KEY=''
export SG_WEB_HOST='api.sendgrid.com'
export SG_WEB_PROTOCOL='HTTPS'
export SG_SMTP_ADDRESS=''
export SG_DOMAIN=''
export SG_PORT='TCP 443'


I investigated and tried it for about 6 hours, but it did not solve it.
If anyone knows, we would appreciate it if you could answer.
Thanks for your cooperation.

  • Answer # 1

    Currently I am testing it locally, so I want to enable mail from that environment.

    So, for the moment, I think it is desirable to check the mail transmission with letter_opener, letter_opener_web.
    Reference: Check the email sent from rails during development

    I thought that if you do not use SendGrid, you cannot send because there is no smtp server. Is it wrong?

    Other than SendGrid, you can also send by Gmail, for example.