-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3423ae
commit db27584
Showing
5 changed files
with
40 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,8 +108,10 @@ super_admin_user_ids = | |
|> Enum.filter(& &1) | ||
|
||
env = get_var_from_path_or_env(config_dir, "ENVIRONMENT", "prod") | ||
mailer_adapter = get_var_from_path_or_env(config_dir, "MAILER_ADAPTER", "Bamboo.SMTPAdapter") | ||
mailer_email = get_var_from_path_or_env(config_dir, "MAILER_EMAIL", "[email protected]") | ||
mailer_adapter = get_var_from_path_or_env(config_dir, "MAILER_ADAPTER", "Bamboo.Mua") | ||
|
||
mailer_email = | ||
get_var_from_path_or_env(config_dir, "MAILER_EMAIL", "plausible-ce@#{base_url.host}") | ||
|
||
mailer_email = | ||
if mailer_name = get_var_from_path_or_env(config_dir, "MAILER_NAME") do | ||
|
@@ -462,23 +464,21 @@ case mailer_adapter do | |
hackney_opts: [recv_timeout: :timer.seconds(10)], | ||
api_key: get_var_from_path_or_env(config_dir, "SENDGRID_API_KEY") | ||
|
||
"Bamboo.SMTPAdapter" -> | ||
config :plausible, Plausible.Mailer, | ||
adapter: Bamboo.SMTPAdapter, | ||
server: get_var_from_path_or_env(config_dir, "SMTP_HOST_ADDR", "mail"), | ||
hostname: base_url.host, | ||
port: get_var_from_path_or_env(config_dir, "SMTP_HOST_PORT", "25"), | ||
username: get_var_from_path_or_env(config_dir, "SMTP_USER_NAME"), | ||
password: get_var_from_path_or_env(config_dir, "SMTP_USER_PWD"), | ||
tls: :if_available, | ||
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"], | ||
ssl: get_var_from_path_or_env(config_dir, "SMTP_HOST_SSL_ENABLED") || false, | ||
retries: get_var_from_path_or_env(config_dir, "SMTP_RETRIES") || 2, | ||
no_mx_lookups: get_var_from_path_or_env(config_dir, "SMTP_MX_LOOKUPS_ENABLED") || true | ||
|
||
"Bamboo.Mua" -> | ||
smtp_adapter when smtp_adapter in ["Bamboo.SMTPAdapter", "Bamboo.Mua"] -> | ||
config :plausible, Plausible.Mailer, adapter: Bamboo.Mua | ||
|
||
if smtp_adapter == "Bamboo.SMTPAdapter" do | ||
Logger.warning( | ||
"Bamboo.SMTPAdapter has been replaced with Bamboo.Mua, falling back to using Bamboo.Mua" | ||
) | ||
end | ||
|
||
for env_var <- ["SMTP_MX_LOOKUPS_ENABLED", "SMTP_RETRIES", "SMTP_HOST_SSL_ENABLED"] do | ||
if get_var_from_path_or_env(config_dir, env_var) do | ||
Logger.warning("#{env_var} env var is no longer supported") | ||
end | ||
end | ||
|
||
if relay = get_var_from_path_or_env(config_dir, "SMTP_HOST_ADDR") do | ||
port = get_int_from_path_or_env(config_dir, "SMTP_HOST_PORT", 25) | ||
username = get_var_from_path_or_env(config_dir, "SMTP_USER_NAME") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ defmodule Plausible.ConfigTest do | |
describe "mailer" do | ||
test "mailer email default" do | ||
env = [{"MAILER_EMAIL", nil}] | ||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "hello@plausible.local" | ||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "plausible-ce@localhost" | ||
end | ||
|
||
test "mailer email custom" do | ||
|
@@ -16,29 +16,19 @@ defmodule Plausible.ConfigTest do | |
env = [{"MAILER_EMAIL", nil}, {"MAILER_NAME", "John"}] | ||
|
||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == | ||
{"John", "hello@plausible.local"} | ||
{"John", "plausible-ce@localhost"} | ||
|
||
env = [{"MAILER_EMAIL", "[email protected]"}, {"MAILER_NAME", "John"}] | ||
|
||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == | ||
{"John", "[email protected]"} | ||
end | ||
|
||
test "defaults to Bamboo.SMTPAdapter" do | ||
test "defaults to Bamboo.Mua" do | ||
env = {"MAILER_ADAPTER", nil} | ||
|
||
assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [ | ||
adapter: Bamboo.SMTPAdapter, | ||
server: "mail", | ||
hostname: "localhost", | ||
port: "25", | ||
username: nil, | ||
password: nil, | ||
tls: :if_available, | ||
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"], | ||
ssl: false, | ||
retries: 2, | ||
no_mx_lookups: true | ||
adapter: Bamboo.Mua | ||
] | ||
end | ||
|
||
|
@@ -113,7 +103,7 @@ defmodule Plausible.ConfigTest do | |
] | ||
end | ||
|
||
test "Bamboo.SMTPAdapter" do | ||
test "Bamboo.SMTPAdapter is deprecated" do | ||
env = [ | ||
{"MAILER_ADAPTER", "Bamboo.SMTPAdapter"}, | ||
{"SMTP_HOST_ADDR", "localhost"}, | ||
|
@@ -125,19 +115,22 @@ defmodule Plausible.ConfigTest do | |
{"SMTP_MX_LOOKUPS_ENABLED", "true"} | ||
] | ||
|
||
assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [ | ||
{:adapter, Bamboo.SMTPAdapter}, | ||
{:server, "localhost"}, | ||
{:hostname, "localhost"}, | ||
{:port, "2525"}, | ||
{:username, "neo"}, | ||
{:password, "one"}, | ||
{:tls, :if_available}, | ||
{:allowed_tls_versions, [:tlsv1, :"tlsv1.1", :"tlsv1.2"]}, | ||
{:ssl, "true"}, | ||
{:retries, "3"}, | ||
{:no_mx_lookups, "true"} | ||
] | ||
log = | ||
ExUnit.CaptureLog.capture_log(fn -> | ||
assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [ | ||
adapter: Bamboo.Mua, | ||
auth: [username: "neo", password: "one"], | ||
relay: "localhost", | ||
port: 2525 | ||
] | ||
end) | ||
|
||
assert log =~ | ||
"[warning] Bamboo.SMTPAdapter has been replaced with Bamboo.Mua, falling back to using Bamboo.Mua" | ||
|
||
assert log =~ "[warning] SMTP_MX_LOOKUPS_ENABLED env var is no longer supported" | ||
assert log =~ "[warning] SMTP_RETRIES env var is no longer supported" | ||
assert log =~ "[warning] SMTP_HOST_SSL_ENABLED env var is no longer supported" | ||
end | ||
|
||
test "Bamboo.Mua (no config)" do | ||
|