-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add same smtp mail backend for marketing and for info
- Loading branch information
Showing
8 changed files
with
75 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
SIHL_SECRET=secret | ||
SIHL_SECRET=secretsecretsecret | ||
DATABASE_URL=postgres://admin:password@127.0.0.1:5432/dev | ||
DATABASE_POOL_SIZE=10 | ||
SMTP_SENDER=sender@example.com | ||
SMTP_PORT=587 | ||
SMTP_USERNAME=user | ||
SMTP_HOST=smtp.example.com | ||
SMTP_START_TLS=true | ||
SMTP_PASSWORD=yourpassword | ||
CA_DIR=/etc/ssl/certs |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SMTP_SENDER=sender@example.com | ||
SMTP_USERNAME=user | ||
SMTP_PASSWORD=yourpassword | ||
SMTP_HOST=smtp.example.com | ||
SMTP_PORT=587 | ||
SMTP_START_TLS=true | ||
CA_DIR=/etc/ssl/certs |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
(library | ||
(name service) | ||
(libraries sihl sihl-user sihl-queue)) | ||
(libraries sihl sihl-user sihl-queue sihl-email)) |
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 |
---|---|---|
@@ -1,3 +1,57 @@ | ||
module Migration = Sihl.Database.Migration.PostgreSql | ||
module User = Sihl_user.PostgreSql | ||
module Queue = Sihl_queue.PostgreSql | ||
|
||
module MarketingSmtpConfig = struct | ||
let config () = | ||
Lwt.return | ||
Sihl_email. | ||
{ sender = "marketing@vinniespiz.za" | ||
; username = "vinnie" | ||
; password = "pinapple0nPizz4" | ||
; hostname = "smtp.example.com" | ||
; port = Some 587 | ||
; start_tls = true | ||
; ca_path = Some "/etc/ssl/certs" | ||
; ca_cert = None | ||
; console = Some true | ||
} | ||
;; | ||
end | ||
|
||
module InfoSmtpConfig = struct | ||
let config () = | ||
let open Lwt.Syntax in | ||
Lwt_io.with_file ~mode:Lwt_io.Input "config/mail.cfg" (fun file -> | ||
let* content = Lwt_stream.to_list @@ Lwt_io.read_lines file in | ||
let config = | ||
content | ||
|> Stdlib.List.map (Stdlib.String.split_on_char '=') | ||
|> Stdlib.List.map (function | ||
| [] -> "", "" | ||
| [ key ] -> key, "" | ||
| [ key; value ] -> key, value | ||
| key :: values -> key, Stdlib.String.concat "" values) | ||
in | ||
Lwt.return | ||
Sihl_email. | ||
{ sender = Stdlib.List.assoc "SMTP_SENDER" config | ||
; username = Stdlib.List.assoc "SMTP_USERNAME" config | ||
; password = Stdlib.List.assoc "SMTP_PASSWORD" config | ||
; hostname = Stdlib.List.assoc "SMTP_HOST" config | ||
; port = | ||
Option.map int_of_string | ||
@@ Stdlib.List.assoc_opt "SMTP_SENDER" config | ||
; start_tls = | ||
bool_of_string @@ Stdlib.List.assoc "SMTP_SENDER" config | ||
; ca_path = Stdlib.List.assoc_opt "SMTP_SENDER" config | ||
; ca_cert = Stdlib.List.assoc_opt "SMTP_SENDER" config | ||
; console = | ||
Option.map bool_of_string | ||
@@ Stdlib.List.assoc_opt "SMTP_SENDER" config | ||
}) | ||
;; | ||
end | ||
|
||
module MarketingMail = Sihl_email.MakeSmtp (MarketingSmtpConfig) | ||
module InfoMail = Sihl_email.MakeSmtp (InfoSmtpConfig) |