{"id":13609641,"url":"https://github.com/maxneuvians/pique","last_synced_at":"2025-05-01T23:30:56.149Z","repository":{"id":57533735,"uuid":"244198362","full_name":"maxneuvians/pique","owner":"maxneuvians","description":"An elixir SMTP server that makes message inspection easier","archived":false,"fork":false,"pushed_at":"2020-03-02T00:43:04.000Z","size":20,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T08:02:25.386Z","etag":null,"topics":["elixir","smtp-server"],"latest_commit_sha":null,"homepage":"","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/maxneuvians.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":"2020-03-01T18:03:58.000Z","updated_at":"2024-04-25T08:02:25.387Z","dependencies_parsed_at":"2022-09-26T18:21:13.476Z","dependency_job_id":null,"html_url":"https://github.com/maxneuvians/pique","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/maxneuvians%2Fpique","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fpique/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fpique/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fpique/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxneuvians","download_url":"https://codeload.github.com/maxneuvians/pique/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224281499,"owners_count":17285675,"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":["elixir","smtp-server"],"created_at":"2024-08-01T19:01:36.701Z","updated_at":"2024-11-12T13:29:04.428Z","avatar_url":"https://github.com/maxneuvians.png","language":"Elixir","funding_links":[],"categories":["Elixir"],"sub_categories":[],"readme":"# Pique\n\nThis project is an elixir wrapper around the excellent [`gen_smtp` server](https://github.com/gen-smtp/gen_smtp) that makes SMTP inspection easier through the registration of handlers. \n\n## Rational or Why do I need this?\n\nThe internet is awesome - sending emails is ok. Email is made more awesome by services like Amazon SES and Mailgun that allow you to send emails  using APIs - especially if you allow you customers to send email on your behalf through your own API. It gives you an opportunity to scan those  emails before they go out for content that should not be in there (ex. personal identifiable information).\n\nHowever, some customers only use SMTP and can not use your awesome API, what then? How do you have the same level of introspection into the emails that are sent through SMTP as through your API? Simple, build your own SMTP server that then pipes the message to that API.\n\nThis package uses the server provided by [`gen_smtp`](https://github.com/gen-smtp/gen_smtp), and allows you to register handlers with various SMTP actions, so that you don't have to deal with all the SMTP stuff, but can focus on what matters. \n\n## Usage\n\nUsing your `Mix.Config` files you can specify a number of `handlers` and a `sender` whose behaviour is defined in `lib/behaviours/handler.ex` and `lib/behaviours/sender.ex` respectively. There exist default `handlers` that just pass through the data and a default `sender` that logs the SMTP message to the console. Best to use an example:\n\nIf I wanted to block all SMTP messages being sent from a specific email address before they get sent I might write a `handler` like this:\n\n```elixir\ndefmodule MyApp.MailHander do\n  @behaviour Pique.Behaviours.Handler\n\n  def handle(\"nefarious.fellow@canada.org\"), do: {:error, \"Go away nefarious fellow\"}\n  def handle(email), do: {:ok, email}\n\nend\n```\n\nand register that `handler` using my config:\n\n```elixir\nconfig :pique,\n  mail_handler: MyApp.MailHander\n```\n\nSimilary if I actually wanted to send my email through AWS SES I could create a new `sender`:\n\n```elixir\ndefmodule MyApp.SESSender do\n  @behaviour Pique.Behaviours.Sender\n  alias ExAws.{SES}\n\n  def send(state) do\n    SES.send_raw_email(state[:data])\n    |\u003e ExAws.request\n    {:ok, state[:data], state}\n  end\n\nend\n```\n\nand register that `handler` using my config:\n\n```elixir\nconfig :pique,\n  sender: MyApp.SESSender\n```\n\nI have thereby created some amorphous monster of SMTP-\u003eSES with custom logic.\n\nBelow is a table of each available `handler` and what it does:\n\n| Type | Config Name | Default | Description |\n|---|---|---|---|\n| Auth | `auth_handler` | `lib/handlers/auth.ex` | Handles any authentication requests |\n| Data | `data_handler` | `lib/handlers/data.ex` | Handles the body of the email to be sent |\n| Mail | `mail_handler` | `lib/handlers/mail.ex` | Handles the from address |\n| Rcpt | `rcpt_handler` | `lib/handlers/rcpt.ex` | Handles any recipients of the email, including bcc |\n| Send | `sender` | `lib/senders/logger.ex` | Handles the sending of the message, by default logs instead of sending it |\n\n## Installation\n\nThe package can be installed by adding `pique` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:pique, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n## Documentation\n\nDocumentation can be found at [https://hexdocs.pm/pique](https://hexdocs.pm/pique).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxneuvians%2Fpique","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxneuvians%2Fpique","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxneuvians%2Fpique/lists"}