Elixir wrapper for the MailJet API.
- Add
mailjex
to your list of dependencies in mix.exs:
def deps do
[{:mailjex, "~> 0.1.5"}]
end
then...
mix deps.get
- Ensure
mailjex
is started before your application (not required for Elixir >= 1.4)
def application do
[applications: [:mailjex]]
end
- Add configuration to your app:
config :mailjex,
api_base: "https://api.mailjet.com/v3",
public_api_key: "<your public key>",
private_api_key: "<your private key>"
development_mode: true | false
- Example usage:
iex> body = %{
...> "FromEmail": "[email protected]",
...> "FromName": "Mailjet Pilot",
...> "Subject": "Your email flight plan!",
...> "MJ-TemplateID": "999902",
...> "MJ-TemplateLanguage": true,
...> "Vars": %{"name": "Alice"},
...> "Recipients": [%{"Email": "[email protected]"}]
...> }
iex> Mailjex.Delivery.send(body)
When running in development or test environments you may not want to actually send emails. You can disable the sending of email and instead have the body of your request logged to the screen.
You can do this by setting development_mode: true
in your configuration file for your environment.
You can read the docs here
If you are making changes to this codebase and want to test your code, you will need to copy the sample secret file.
cp config/secret.sample.exs config/secret.exs
Then add your MailJet public and private keys.
Resources that are implemented so far.
- Delivery (sending emails)
- Messages
- Template
- Sender Templates and Domains
- Contact Lists
- Contact
- Campaigns
- Statistics
- Parse API
- Event API
- Account Settings
- System
Areas of the codebase that can be improved.
- Testing error cases
The mailjex
lib is released under the MIT License.