diff --git a/README.md b/README.md index fb73cf1..a7f1e2c 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ defp application do end ``` +Configure adapter options. + +```elixir +config :sendgrid, + adapter: {Tesla.Adapter.Httpc, [timeout: 30000, proxy: "http://proxy:9999"]} +``` + ## Phoenix Views You can use Phoenix Views to set your HTML and text content of your emails. You just have diff --git a/config/config.exs b/config/config.exs index e9d747f..6457285 100644 --- a/config/config.exs +++ b/config/config.exs @@ -4,4 +4,5 @@ config :sendgrid, api_key: {:system, "SENDGRID_API_KEY"}, sandbox_enable: true, phoenix_view: SendGrid.EmailView, - test_address: System.get_env("SENDGRID_TEST_EMAIL") + test_address: System.get_env("SENDGRID_TEST_EMAIL"), + adapter: {Tesla.Adapter.Httpc, []} \ No newline at end of file diff --git a/lib/sendgrid.ex b/lib/sendgrid.ex index 5269c81..1373320 100644 --- a/lib/sendgrid.ex +++ b/lib/sendgrid.ex @@ -135,6 +135,8 @@ defmodule SendGrid do end end + defp adapter, do: Application.get_env(:sendgrid, :adapter) + defp build_client(api_key) do middleware = [ {Tesla.Middleware.BaseUrl, "https://api.sendgrid.com"}, @@ -142,7 +144,7 @@ defmodule SendGrid do {Tesla.Middleware.Headers, [{"Authorization", "Bearer #{api_key}"}]} ] - Tesla.client(middleware) + Tesla.client(middleware, adapter()) end defp query_opts(opts) do