Add smtp conf

This commit is contained in:
Alex
2022-07-25 22:54:06 +02:00
parent dfe5d7538e
commit ab4d68f3a7
5 changed files with 19 additions and 14 deletions

View File

@@ -114,9 +114,6 @@ AWS_SECRET_ACCESS_KEY | - | - | _(only if s3 is used)_ Your AWS Secret Access Ke
AWS_S3_BUCKET | - | - | _(only if s3 is used)_ The name of the bucket where the presentation files will be stored
AWS_S3_REGION | - | - | _(only if s3 is used)_ The region where the bucket is located
- **PRESENTATION_STORAGE** : `local` or `s3`, define where the presentation files will be stored.
- **MAIL** : `local` or `smtp`, define how the mails will be sent.
### Installation
1. Clone the repo
@@ -153,10 +150,9 @@ If you have configured `MAIL` to `local`, you can access to the mailbox at [`loc
You can build the app with Docker:
```sh
docker build -t claper .
docker run -p 4000:4000 -d claper
```
docker build -t claper .
docker run -p 4000:4000 -d claper
```
<!-- USAGE EXAMPLES -->
## Usage

View File

@@ -75,9 +75,16 @@ if config_env() == :prod do
# For this example you need include a HTTP client required by Swoosh API client.
# Swoosh supports Hackney and Finch out of the box:
#
#config :claper, Claper.Mailer,
# adapter: Swoosh.Adapters.Postmark,
# api_key: System.get_env("SWOOSH_API_KEY")
config :claper, Claper.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: System.get_env("SMTP_RELAY"),
username: System.get_env("SMTP_USERNAME"),
password: System.get_env("SMTP_PASSWORD"),
ssl: System.get_env("SMTP_SSL", "true") == "true",
tls: String.to_atom(System.get_env("SMTP_TLS", "always")), # always, never, if_available
auth: String.to_atom(System.get_env("SMTP_AUTH", "always")), # always, never, if_available
port: String.to_integer(System.get_env("SMTP_PORT", "25"))
config :swoosh, :api_client, Swoosh.ApiClient.Finch

View File

@@ -5,7 +5,7 @@ defmodule ClaperWeb.Notifiers.UserNotifier do
def magic(email, url) do
new()
|> to(email)
|> from({"Alex from Claper", "alex@claper.co"})
|> from({System.get_env("MAIL_FROM_NAME", "Claper"), System.get_env("MAIL_FROM", "hello@claper.co")})
|> subject(gettext("Connect to Claper"))
|> render_body("magic.html", %{url: url})
end
@@ -13,7 +13,7 @@ defmodule ClaperWeb.Notifiers.UserNotifier do
def welcome(email) do
new()
|> to(email)
|> from({"Alex from Claper", "alex@claper.co"})
|> from({System.get_env("MAIL_FROM_NAME", "Claper"), System.get_env("MAIL_FROM", "hello@claper.co")})
|> subject(gettext("Next steps to boost your presentations"))
|> render_body("welcome.html", %{email: email})
end
@@ -21,7 +21,7 @@ defmodule ClaperWeb.Notifiers.UserNotifier do
def update_email(user, url) do
new()
|> to(user.email)
|> from({"Alex from Claper", "alex@claper.co"})
|> from({System.get_env("MAIL_FROM_NAME", "Claper"), System.get_env("MAIL_FROM", "hello@claper.co")})
|> subject(gettext("Update email instructions"))
|> render_body("change.html", %{user: user, url: url})
end

View File

@@ -61,7 +61,8 @@ defmodule Claper.MixProject do
{:mogrify, "~> 0.9.1"},
{:libcluster, "~> 3.3"},
{:porcelain, "~> 2.0"},
{:hackney, "~> 1.18"}
{:hackney, "~> 1.18"},
{:gen_smtp, "~> 1.2"}
]
end

View File

@@ -21,6 +21,7 @@
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"finch": {:hex, :finch, "0.10.2", "9ad27d68270d879f73f26604bb2e573d40f29bf0e907064a9a337f90a16a0312", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dd8b11b282072cec2ef30852283949c248bd5d2820c88d8acc89402b81db7550"},
"floki": {:hex, :floki, "0.32.0", "f915dc15258bc997d49be1f5ef7d3992f8834d6f5695270acad17b41f5bcc8e2", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "1c5a91cae1fd8931c26a4826b5e2372c284813904c8bacb468b5de39c7ececbd"},
"gen_smtp": {:hex, :gen_smtp, "1.2.0", "9cfc75c72a8821588b9b9fe947ae5ab2aed95a052b81237e0928633a13276fd3", [:rebar3], [{:ranch, ">= 1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "5ee0375680bca8f20c4d85f58c2894441443a743355430ff33a783fe03296779"},
"gettext": {:hex, :gettext, "0.19.1", "564953fd21f29358e68b91634799d9d26989f8d039d7512622efb3c3b1c97892", [:mix], [], "hexpm", "10c656c0912b8299adba9b061c06947511e3f109ab0d18b44a866a4498e77222"},
"hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
"hashids": {:hex, :hashids, "2.0.5", "d9839924c8221b954da8b110eda3e59c2c03df0389bac6e7d0e535f937033df1", [:mix], [], "hexpm", "ef47d8679f20d7bea59d0d49c202258c89f61b9b741bd3dceef2c1985cf95554"},