carbon_sendgrid_adapter

0.1.0 released

Carbon SendGrid Adapter

Integration for Lucky's Carbon email library and SendGrid.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      carbon_sendgrid_adapter:
        github: luckyframework/carbon_sendgrid_adapter
    
  2. Run shards install

Usage

Create an environment variable called SEND_GRID_KEY with your SendGrid api key.

Update your config/email.cr file to use SendGrid

require "carbon_sendgrid_adapter"

BaseEmail.configure do |settings|
 if Lucky::Env.production?
   send_grid_key = send_grid_key_from_env
   settings.adapter = Carbon::SendGridAdapter.new(api_key: send_grid_key)
 else
  settings.adapter = Carbon::DevAdapter.enw
 end
end

private def send_grid_key_from_env
  ENV["SEND_GRID_KEY"]? || raise_missing_key_message
end

private def raise_missing_key_message
  puts "Missing SEND_GRID_KEY. Set the SEND_GRID_KEY env variable to 'unused' if not sending emails, or set the SEND_GRID_KEY ENV var.".colorize.red
  exit(1)
end

Contributing

  1. Fork it (https://github.com/your-github-user/carbon_sendgrid_adapter/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

carbon_sendgrid_adapter:
  github: luckyframework/carbon_sendgrid_adapter
  version: ~> 0.1.0
License MIT
Crystal >= 0.36.1, < 2.0.0

Authors

Dependencies 2

  • carbon ~> 0.2.0
    {'github' => 'luckyframework/carbon', 'version' => '~> 0.2.0'}
  • habitat ~> 0.4.7
    {'github' => 'luckyframework/habitat', 'version' => '~> 0.4.7'}

Development Dependencies 2

  • ameba ~> 0.14.2
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 0.14.2'}
  • lucky_env ~> 0.1.1
    {'github' => 'luckyframework/lucky_env', 'version' => '~> 0.1.1'}

Dependents 1

Last synced .
search fire star recently