This is luckyframework/carbon's adapter for Mailgun: https://www.mailgun.com
https://github.com/luckyframework/carbon
-
Add the dependency to your
shard.yml
:dependencies: carbon_mailgun_adapter: github: atnos/carbon_mailgun_adapter
-
Run
shards install
Set your MAILGUN_API_KEY
, MAILGUN_BASE_URI
and MAILGUN_SEND_DOMAIN
variable inside .env
MAILGUN_API_KEY=key-XXXXXXXXXXXXXXXXXXXXXXXXXX
MAILGUN_BASE_URI=api.mailgun.net
MAILGUN_SEND_DOMAIN=sandboxXXXXXXXXXXXXXXXXXXXXX.mailgun.org
and update your config/email.cr
file with:
require "carbon_mailgun_adapter"
BaseEmail.configure do |settings|
if Lucky::Env.production?
mailgun_key = mailgun_key_from_env
mailgun_base_uri = mailgun_base_uri_from_env
mailgun_send_domain = mailgun_send_domain_from_env
settings.adapter = Carbon::MailgunAdapter.new(api_key: mailgun_key, base_uri: mailgun_base_uri, send_domain: mailgun_send_domain)
else
settings.adapter = Carbon::DevAdapter.new(print_emails: true)
end
end
private def mailgun_key_from_env
ENV["MAILGUN_API_KEY"]? || raise_missing_key_message
end
private def mailgun_base_uri_from_env
ENV["MAILGUN_BASE_URI"]? || raise_missing_base_uri_message
end
private def mailgun_send_domain_from_env
ENV["MAILGUN_SEND_DOMAIN"]? || raise_missing_send_domain_message
end
private def raise_missing_key_message
puts "Missing MAILGUN_API_KEY. Set the MAILGUN_API_KEY env variable to '' if not sending emails, or set the MAILGUN_API_KEY ENV var.".colorize.red
exit(1)
end
private def raise_missing_base_uri_message
puts "Missing MAILGUN_BASE_URI ENV var.".colorize.red
exit(1)
end
private def raise_missing_send_domain_message
puts "Missing MAILGUN_SEND_DOMAIN ENV var.".colorize.red
exit(1)
end
- Fork it (https://github.com/your-github-user/carbon_mailgun_adapter/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Bruno Perles - creator and maintainer