{"id":13507842,"url":"https://github.com/antp/mailer","last_synced_at":"2026-02-22T19:02:10.250Z","repository":{"id":24896998,"uuid":"28313379","full_name":"antp/mailer","owner":"antp","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-03T18:06:55.000Z","size":43,"stargazers_count":41,"open_issues_count":3,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T17:08:39.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T21:13:56.000Z","updated_at":"2023-09-01T08:48:58.000Z","dependencies_parsed_at":"2022-08-23T09:50:50.797Z","dependency_job_id":null,"html_url":"https://github.com/antp/mailer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antp%2Fmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antp%2Fmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antp%2Fmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antp%2Fmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antp","download_url":"https://codeload.github.com/antp/mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301963,"owners_count":20755512,"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:00:40.756Z","updated_at":"2025-10-21T14:46:51.972Z","avatar_url":"https://github.com/antp.png","language":"Elixir","funding_links":[],"categories":["Email"],"sub_categories":[],"readme":"# Mailer\n\nA simple SMTP mailer.\n\nThis can be used to send one off emails such welcome emails after signing up\nto a service or password recovery emails.\n\nMailer is built upon ```gen_smtp``` and uses it to deliver emails. \n\n## What it is not\n\nA mass mailer, just don't do it.\n\n\n## Dependencies\nAdd the following to your applications dependency block in ```mix.exs```.\n\n```elixir\n  {:mailer, github: \"antp/mailer\"}\n```\n\nThen run ```mix deps.get```.\n\nMailer uses ```gen_smtp``` to provide the mailing infrastructure.\n\n## Usage\n\nFirst compose an email with:\n\n```elixir\n  email = Mailer.compose_email(\"from@example.com\", \"to@example.com\", \"Subject\", \"welcome_template\", template_data)\n```\n\nThen send the email with:\n\n```elixir\n   response = Mailer.send(email)\n```\n\nThe response can be checked for failed deliveries.\n\nSuccessful deliveries will have OK in the response such as:\n\n```\n\"2.0.0 Ok: queued as 955CBC01C2\\r\\n\"\n```\n\nFailed deliveries will have a response similar to:\n\n```\n{:error, :retries_exceeded,\n {:network_failure, \"xxx.xxx.xxx.xxx\", {:error, :ehostunreach}}}\n```\n\n### Configuration\nIn your applications ```config.exs``` file you need to add two sections.\n\n#### Template configuration\nAdd a section to detail the location of the templates\n\n```elixir\n  config :mailer,\n    templates: \"priv/templates\"\n```\n\nThe mailer will look for all templates under this path. If you pass 'welcome' as the template name, mailer will look in ```priv/templates/welcome``` to locate the template file.\n\nThe path is relative to the directory that the application is run from. For a normal application setting ```priv/templates``` is correct. If you're application is part of an umbrella application then you will need to set it to the path within the ```apps``` directory such as:\n\n```elixir\n  config :mailer,\n    templates: \"apps/site_mailer/priv/templates\"\n```\nif you run your application from the main umbrella directory.\n\n#### SMTP client configuration\nAs mailer uses ```gen_smtp``` it requires a server to relay mails through.\n\nThe smtp configuration is passed through to ```gen_smtp```, so all options that ```gen_smtp``` supports are available.\n\nOption:       | Values:\n------------- | -------------\nserver        | Address of the email server to relay through.\nhostname      | Hostname of your mail client\ntransport     | :smtp -\u003e deliver mail using smtp (default)\u003cbr /\u003e :test -\u003e deliver mail to a test server\nusername      | username to use in authentication\npassword      | password for the username\ntls           | :always -\u003e always use TLS\u003cbr /\u003e:never -\u003e never use TLS\u003cbr /\u003e:if_available -\u003e use TLS if available (default)\nssl           | :true -\u003e use SSL\u003cbr /\u003e:false -\u003e do not use SSL (default)\nauth          | :if_available -\u003e use authentication if available (default)\nretries       | Number of retries before a send failure is reported\u003cbr /\u003e defaults to 1\n\n\n## Plain text or Multipart email\nMailer will automatically send multipart emails if you have both a ```.txt``` and ```.html``` in the template directory. The ```.html``` template is optional.\n\n### To send a welcome email:\nSending plain text only:\n\n```elixir\npriv/templates/welcome/welcome.txt\n```\n\nSending a multipart email:\n\n```elixir\npriv/templates/welcome/welcome.txt\npriv/templates/welcome/welcome.html\n```\n\n## Internationalisation\nWhen sending a mail it is possible to add a country code. When the mail is composed this will be added to the template path to further qualify the template lookup.\n\nIf for example to wanted to support both English and French the template directory structure would look like the following:\n\n```elixir\npriv/templates/welcome/en/welcome.txt\npriv/templates/welcome/en/welcome.html\npriv/templates/welcome/fr/welcome.txt\npriv/templates/welcome/fr/welcome.html\n```\nBy including the country code in the compose call, Mailer will render the correct localised template.\n\n```elixir\nMailer.compose_email(\"from@example.com\", \"to@example.com\", \"Subject\", \"welcome\", data, \"en\")\n```\nif the template files are not found in the language directory Mailer will look for a default template to send in the parent directory.\n\n```elixir\npriv/templates/welcome \u003c- default location of templates\npriv/templates/welcome/\u003ccountry_code\u003e \u003c- internationalised templates\n```\n\n\n\n# Author\n\nCopyright © 2014 Component X Software, Antony Pinchbeck\n\nReleased under Apache 2 License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantp%2Fmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantp%2Fmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantp%2Fmailer/lists"}