Shield.Notifier
Shield Notifier is an external package for Shield package notifications. Currently, it only supports email with text based confirmation and password recovery email templates using Bamboo.
Installation
The package can be installed as:
-
Add
shield_notifierto your list of dependencies inmix.exs:
```elixir
def deps do
[{:shield_notifier, "~> 0.2"}]
end
```-
Ensure
shield_notifieris started before your application:
```elixir
def application do
[applications: [:shield_notifier]]
end
```- Add the following lines to your config:
```elixir
config :shield_notifier,
channels: %{
email: %{
from: %{
name: {:system, "APP_NAME", "Shield Notifier"},
email: {:system, "APP_FROM_EMAIL", "no-reply@localhost"}
}
}
}
```- Add your favorite Bamboo adapter config for prod env as below
```elixir
config :shield_notifier, Shield.Notifier.Mailer,
adapter: Bamboo.SendgridAdapter,
api_key: SYSTEM.get_env("SENDGRID_API_KEY")
```Usage
Email Channel
To send confirmation email:
Shield.Notifier.Channel.Email.deliver(
["recipient@example.com"],
:confirmation,
%{identity: "Recipient", confirmation_url: "https://xyz.com/con?t=1234"}
)To send password recovery email:
Shield.Notifier.Channel.Email.deliver(
["recipient@example.com"],
:recover_password,
%{identity: "Recipient", recover_password_url: "https://xyz.com/rec?t=1op2"}
)Channel Implementation
If you need to create your own channels, you can create channels by using Shield.Notifier.Channel behaviour. All you need to implement a deliver function.
deliver(recipients :: list, template :: atom, data :: any) :: anyContributing
Issues, Bugs, Documentation, Enhancements
Fork the project
Make your improvements and write your tests.
Document what you did/change.
Make a pull request.
Todo
- HTML email templates.