{"id":13509557,"url":"https://github.com/chrismccord/mailgun","last_synced_at":"2025-05-16T18:08:38.040Z","repository":{"id":21347319,"uuid":"24664370","full_name":"chrismccord/mailgun","owner":"chrismccord","description":"Elixir Mailgun Client","archived":false,"fork":false,"pushed_at":"2022-10-22T00:53:27.000Z","size":52,"stargazers_count":195,"open_issues_count":21,"forks_count":95,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T16:59:13.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrismccord.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-01T03:20:45.000Z","updated_at":"2025-01-25T07:49:50.000Z","dependencies_parsed_at":"2022-08-20T19:30:09.919Z","dependency_job_id":null,"html_url":"https://github.com/chrismccord/mailgun","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismccord%2Fmailgun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismccord%2Fmailgun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismccord%2Fmailgun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismccord%2Fmailgun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrismccord","download_url":"https://codeload.github.com/chrismccord/mailgun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:09.562Z","updated_at":"2025-05-16T18:08:38.023Z","avatar_url":"https://github.com/chrismccord.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"# Elixir Mailgun Client [![Build Status](https://travis-ci.org/chrismccord/mailgun.svg)](https://travis-ci.org/chrismccord/mailgun)\n\n\n```elixir\n# config/config.exs\n\nconfig :my_app, mailgun_domain: \"https://api.mailgun.net/v3/mydomain.com\",\n                mailgun_key: \"key-##############\"\n\n\n# lib/mailer.ex\ndefmodule MyApp.Mailer do\n  @config domain: Application.get_env(:my_app, :mailgun_domain),\n          key: Application.get_env(:my_app, :mailgun_key)\n  use Mailgun.Client, @config\n                      \n\n  @from \"info@example.com\"\n\n  def send_welcome_text_email(user) do\n    send_email to: user.email,\n               from: @from,\n               subject: \"hello!\",\n               text: \"Welcome!\"\n  end\n\n  def send_welcome_html_email(user) do\n    send_email to: user.email,\n               from: @from,\n               subject: \"hello!\",\n               html: \"\u003cstrong\u003eWelcome!\u003c/strong\u003e\"\n  end\n\n # attachments expect a list of maps. Each map should have a filename and path/content\n\n  def send_greetings(user, file_path) do\n    send_email to: user.email,\n               from: @from,\n               subject: \"Happy b'day\",\n               html: \"\u003cstrong\u003eCheers!\u003c/strong\u003e\",\n               attachments: [%{path: file_path, filename: \"greetings.png\"}]\n  end\n\n  def send_invoice(user) do\n    pdf = Invoice.create_for(user) # a string\n    send_email to: user.email,\n               from: @from,\n               subject: \"Invoice\",\n               html: \"\u003cstrong\u003eYour Invoice\u003c/strong\u003e\",\n               attachments: [%{content: pdf, filename: \"invoice.pdf\"}]\n  end\nend\n\n\niex\u003e MyApp.Mailer.send_welcome_text_email(user)\n{:ok, ...}\n```\n\n### Installation\n\nAdd mailgun to your `mix.exs` dependencies:\n\n  ```elixir\n  def deps do\n    [ {:mailgun, \"~\u003e 0.1.2\"} ]\n  end\n  ```\n\n### Test mode\nFor testing purposes mailgun can output emails to a local file instead of\nactually sending them. Just set the `mode` configuration key to `:test`\nand the `test_file_path` to where you want that file to appear.\n\n```elixir\n# lib/mailer.ex\ndefmodule MyApp.Mailer do\n  @config domain: Application.get_env(:my_app, :mailgun_domain),\n          key: Application.get_env(:my_app, :mailgun_key),\n          mode: :test,\n          test_file_path: \"/tmp/mailgun.json\"\n  use Mailgun.Client, @config\n\n...\nend\n```\n\n### httpc options\nUnder the hood the client uses [`httpc`](http://erlang.org/doc/man/httpc.html)\nto call Mailgun REST API. You can inject any valid `httpc` options to your\noutbound requests by defining them within `httpc_opts` config entry:\n\n```elixir\n# lib/mailer.ex\ndefmodule MyApp.Mailer do\n  @config domain: Application.get_env(:my_app, :mailgun_domain),\n          key: Application.get_env(:my_app, :mailgun_key),\n          httpc_opts: [connect_timeout: 2000, timeout: 3000]\n  use Mailgun.Client, @config\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismccord%2Fmailgun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismccord%2Fmailgun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismccord%2Fmailgun/lists"}