{"id":13509619,"url":"https://github.com/alexgaribay/sendgrid_elixir","last_synced_at":"2025-10-21T18:48:13.584Z","repository":{"id":46407928,"uuid":"52736452","full_name":"alexgaribay/sendgrid_elixir","owner":"alexgaribay","description":"Create and send composable emails with Elixir and SendGrid.","archived":false,"fork":false,"pushed_at":"2024-04-12T19:35:16.000Z","size":90,"stargazers_count":86,"open_issues_count":13,"forks_count":45,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-10T02:55:17.852Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexgaribay.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-28T18:30:25.000Z","updated_at":"2024-03-20T00:45:47.000Z","dependencies_parsed_at":"2024-06-20T11:06:43.548Z","dependency_job_id":"62cd4a1d-8b2b-4e69-8b76-b21302be83a9","html_url":"https://github.com/alexgaribay/sendgrid_elixir","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexgaribay%2Fsendgrid_elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexgaribay%2Fsendgrid_elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexgaribay%2Fsendgrid_elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexgaribay%2Fsendgrid_elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexgaribay","download_url":"https://codeload.github.com/alexgaribay/sendgrid_elixir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847060,"owners_count":20357317,"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:10.437Z","updated_at":"2025-10-21T18:48:13.227Z","avatar_url":"https://github.com/alexgaribay.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"# SendGrid\n\nA wrapper for SendGrid's API to create composable emails.\nCheck the [docs](https://hexdocs.pm/sendgrid/) for complete usage.\n\n## Example\n\n```elixir\nSendGrid.Email.build()\n|\u003e SendGrid.Email.add_to(\"test@email.com\")\n|\u003e SendGrid.Email.put_from(\"test2@email.com\")\n|\u003e SendGrid.Email.put_subject(\"Hello from Elixir\")\n|\u003e SendGrid.Email.put_text(\"Sent with Elixir\")\n|\u003e SendGrid.Mail.send()\n```\n\n## Installation\n\nAdd the following code to your dependencies in your **`mix.exs`** file:\n\n```elixir\n{:sendgrid, \"~\u003e 2.0\"}\n```\n\n## Configuration\n\nIn one of your configuration files, include your SendGrid API key like this:\n\n```elixir\nconfig :sendgrid,\n  api_key: \"SENDGRID_API_KEY\"\n```\n\nIf you want to use environment variable, use `{:system, \"ENV_NAME\"}` in your config:\n\n```elixir\nconfig :sendgrid,\n  api_key: {:system, \"SENDGRID_API_KEY\"}\n```\n\nIf you'd like to enable sandbox mode (emails won't send but will be validated), add the setting to your config:\n\n```elixir\nconfig :sendgrid,\n  api_key: \"SENDGRID_API_KEY\",\n  sandbox_enable: true\n```\n\nAdd `:sendgrid` to your list of applications if using Elixir 1.3 or lower.\n\n```elixir\ndefp application do\n  [applications: [:sendgrid]]\nend\n```\n\n## Phoenix Views\n\nYou can use Phoenix Views to set your HTML and text content of your emails. You just have\nto provide a view module and template name and you're good to go! Additionally, you can set\na layout to render the view in with `SendGrid.Email.put_phoenix_layout/2`. See `SendGrid.Email.put_phoenix_template/3`\nfor complete usage.\n\n### Examples\n\n```elixir\nimport SendGrid.Email\n\n# Using an HTML template\n%SendGrid.Email{}\n|\u003e put_phoenix_view(MyApp.Web.EmailView)\n|\u003e put_phoenix_template(\"welcome_email.html\", user: user)\n\n# Using a text template\n%SendGrid.Email{}\n|\u003e put_phoenix_view(MyApp.Web.EmailView)\n|\u003e put_phoenix_template(\"welcome_email.txt\", user: user)\n\n# Using both an HTML and text template\n%SendGrid.Email{}\n|\u003e put_phoenix_view(MyApp.Web.EmailView)\n|\u003e put_phoenix_template(:welcome_email, user: user)\n\n\n# Setting the layout\n%SendGrid.Email{}\n|\u003e put_phoenix_layout({MyApp.Web.EmailView, :layout})\n|\u003e put_phoenix_view(MyApp.Web.EmailView)\n|\u003e put_phoenix_template(:welcome_email, user: user)\n```\n\n### Using a Default Phoenix View\n\nYou can set a default Phoenix View to use for rendering templates. Just set the `:phoenix_view` config value\n\n```elixir\nconfig :sendgrid,\n  phoenix_view: MyApp.Web.EmailView\n```\n\n### Using a Default Layout\n\nYou can set a default layout to render your view in. Set the `:phoenix_layout` config value.\n\n```elixir\nconfig :sendgrid,\n  phoenix_layout: {MyApp.Web.EmailView, :layout}\n```\n\n## Personalizations\n\nPersonalizations are used to identify who should receive the email as well as specifics about how you would like the email to be handled.\n\nPersonalizations allow you to define:\n\n- `to`, `cc`, `bcc` - The recipients of your email.\n- `subject` - The subject of your email.\n- `headers` - Any headers you would like to include in your email.\n- `substitutions` - Any substitutions you would like to be made for your email.\n- `custom_args` - Any custom arguments you would like to include in your email.\n- `dynamic_template_data` - Data to send along with a template.\n- `send_at` - A specific time that you would like your email to be sent.\n\nAn `SendGrid.Email` automatically takes these fields and transforms them into a personalization to be sent in the email. However, you can add multiple personalizations to an email and specify different handling instructions for different copies of your email. For example, you could send the same email to both \u003cjohn@example.com\u003e and \u003cjaneexampexample@example.com\u003e, but set each email to be delivered at different times.\n\n### Example\n\n```elixir\nalias SendGrid.{Mail, Email}\npersonalization_1 =\n  Email.build()\n  |\u003e Email.add_to(\"john@example.com\")\n  |\u003e Email.put_subject(\"Exciting news!\")\n  |\u003e Email.to_personalization()\n\npersonalization_2 =\n  Email.build()\n  |\u003e Email.add_to(\"jane@example.com\")\n  |\u003e Email.put_subject(\"We've some exciting news!\")\n  |\u003e Email.to_personalization()\n\nEmail.build()\n|\u003e Email.put_from(\"news@mydomain.com\")\n|\u003e Email.put_text(\"...\")\n|\u003e Email.put_html(\"...\")\n|\u003e Email.add_personalization(personalization_1)\n|\u003e Email.add_personalization(personalization_2)\n|\u003e Mail.send()\n```\n\n### Limitations\n\nThe SendGrid v3 API limits you to 1,000 personalizations per API request. If you need to include more than 1,000 personalizations, please divide these across multiple API requests.\n\n## Testing\n\nTo run the unit tests you will need to create a `config/config.exs` file and provide your own SendGrid API and email address to receive a test email.\n\n```elixir\nuse Mix.Config\n\nconfig :sendgrid,\n  api_key: \"\u003cAPI_KEY\u003e\",\n  phoenix_view: SendGrid.Email.Test.EmailView,\n  test_address: \"recipient@example.com\"\n```\n\nThe `config` directory is excluded from the git repository so your API key and email address will not be committed.\n\nOnce configured you can run the full test suite including integration tests as follows:\n\n```console\nmix test --include integration\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexgaribay%2Fsendgrid_elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexgaribay%2Fsendgrid_elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexgaribay%2Fsendgrid_elixir/lists"}