Skip to content

Instantly share code, notes, and snippets.

@acushlakoncept
Last active September 22, 2021 08:30
Show Gist options
  • Save acushlakoncept/734e0046a3bd92e784aff038cc4bb2a1 to your computer and use it in GitHub Desktop.
Save acushlakoncept/734e0046a3bd92e784aff038cc4bb2a1 to your computer and use it in GitHub Desktop.
# USING SENDGRID
# create your apikey, you will use it as the password
# add gem 'dotenv-rails'
# create .env in the root directory and remember to add it to .gitignore
# Add SENDGRID_PASSWORD=SG.xxxxxxx to .env where "SG.xxxxxxx" is the APIKEY you generated
#First configure Devise email in config/initializers/devise.rb:
# Verify the email as single sender at https://app.sendgrid.com/settings/sender_auth
config.mailer_sender = "[email protected]"
#If you continue to get an error message, did you reboot the server?
#Localhost email testing
#Add the following to config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.perform_caching = false
ActionMailer::Base.smtp_settings = {
:user_name => 'apikey',
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'localhost',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment