Skip to content

Commit b6d1845

Browse files
committed
refactor: uses SMTP instead of SendGrid, so adds Gen_SMTP lib and removes Finch
1 parent 73d7c16 commit b6d1845

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

config/config.exs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,34 @@ config :crawly,
1010
Crawly.Middlewares.UniqueRequest,
1111
{Crawly.Middlewares.UserAgent,
1212
user_agents: [
13-
"[https://simontirant.dev | [email protected]] Hi, I am looking for an Elixir developper position so I made this web crawler."
13+
"[https://simontirant.dev | [email protected]] Hi, I am looking for an Elixir developper position so I made this job scrapping GenServer."
1414
]}
1515
],
1616
pipelines: [
17-
# {Crawly.Pipelines.Validate, fields: [:title, :experience, :url]},
18-
# {Crawly.Pipelines.DuplicatesFilter, item_id: :title},
1917
{Crawly.Pipelines.Validate, fields: [:hash, :html]},
20-
{Crawly.Pipelines.DuplicatesFilter, item_id: :hash},
2118
Crawly.Pipelines.JSONEncoder,
2219
{Crawly.Pipelines.WriteToFile,
2320
extension: "jsonl", folder: "./priv/tmp", include_timestamp: false}
2421
]
2522

26-
config :swoosh, :api_client, Swoosh.ApiClient.Finch
23+
config :swoosh, :api_client, false
2724

2825
config :scrapex, Scrapex.Mailer,
29-
adapter: Swoosh.Adapters.Sendgrid,
30-
api_key: System.get_env("SENDGRID_KEY")
26+
adapter: Swoosh.Adapters.SMTP,
27+
relay: "smtp." <> "#{System.get_env("DOMAIN_NAME")}",
28+
username: System.get_env("SENDER_MAIL"),
29+
password: System.get_env("SENDER_PWD"),
30+
ssl: false,
31+
tls: :always,
32+
auth: :always,
33+
port: 587,
34+
dkim: [
35+
s: System.get_env("SENDER_NAME"),
36+
d: System.get_env("DOMAIN_NAME"),
37+
private_key: {:pem_plain, File.read!("priv/keys/private-key.pem")}
38+
],
39+
retries: 2,
40+
no_mx_lookups: false
3141

3242
config :scrapex,
3343
sender_mail: System.get_env("SENDER_MAIL"),

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ defmodule Scrapex.MixProject do
2323
defp deps do
2424
[
2525
{:crawly, "~> 0.16.0"},
26-
{:finch, "~> 0.16.0"},
2726
{:floki, "~> 0.34.3"},
27+
{:gen_smtp, "~> 1.2"},
2828
{:swoosh, "~> 1.12"}
2929
# {:dep_from_hexpm, "~> 0.3.0"},
3030
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}

0 commit comments

Comments
 (0)