mirror of
https://github.com/penpot/penpot.git
synced 2025-05-15 00:26:37 +02:00
🐛 Fix ssl support on email sending module
This commit is contained in:
parent
3a4563d755
commit
53c358cfd7
2 changed files with 19 additions and 13 deletions
|
@ -271,13 +271,13 @@
|
||||||
::public-uri
|
::public-uri
|
||||||
::redis-uri
|
::redis-uri
|
||||||
::registration-domain-whitelist
|
::registration-domain-whitelist
|
||||||
|
::rpc-rlimit-config
|
||||||
|
|
||||||
::semaphore-process-font
|
::semaphore-process-font
|
||||||
::semaphore-process-image
|
::semaphore-process-image
|
||||||
::semaphore-update-file
|
::semaphore-update-file
|
||||||
::semaphore-auth
|
::semaphore-auth
|
||||||
|
|
||||||
::rpc-rlimit-config
|
|
||||||
::smtp-default-from
|
::smtp-default-from
|
||||||
::smtp-default-reply-to
|
::smtp-default-reply-to
|
||||||
::smtp-host
|
::smtp-host
|
||||||
|
@ -286,8 +286,10 @@
|
||||||
::smtp-ssl
|
::smtp-ssl
|
||||||
::smtp-tls
|
::smtp-tls
|
||||||
::smtp-username
|
::smtp-username
|
||||||
|
|
||||||
::srepl-host
|
::srepl-host
|
||||||
::srepl-port
|
::srepl-port
|
||||||
|
|
||||||
::assets-storage-backend
|
::assets-storage-backend
|
||||||
::storage-assets-fs-directory
|
::storage-assets-fs-directory
|
||||||
::storage-assets-s3-bucket
|
::storage-assets-s3-bucket
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
type (resolve-recipient-type type)]
|
type (resolve-recipient-type type)]
|
||||||
(.addRecipients mmsg type address)
|
(.addRecipients mmsg type address)
|
||||||
mmsg)))
|
mmsg)))
|
||||||
|
|
||||||
(defn- assign-recipients
|
(defn- assign-recipients
|
||||||
[mmsg {:keys [to cc bcc] :as params}]
|
[mmsg {:keys [to cc bcc] :as params}]
|
||||||
(cond-> mmsg
|
(cond-> mmsg
|
||||||
|
@ -139,6 +138,7 @@
|
||||||
(Properties.)
|
(Properties.)
|
||||||
{"mail.user" username
|
{"mail.user" username
|
||||||
"mail.host" host
|
"mail.host" host
|
||||||
|
"mail.debug" (contains? cf/flags :smtp-debug)
|
||||||
"mail.from" default-from
|
"mail.from" default-from
|
||||||
"mail.smtp.auth" (boolean username)
|
"mail.smtp.auth" (boolean username)
|
||||||
"mail.smtp.starttls.enable" tls
|
"mail.smtp.starttls.enable" tls
|
||||||
|
@ -150,17 +150,14 @@
|
||||||
"mail.smtp.connectiontimeout" timeout}))
|
"mail.smtp.connectiontimeout" timeout}))
|
||||||
|
|
||||||
(defn- create-smtp-session
|
(defn- create-smtp-session
|
||||||
[{:keys [debug] :or {debug false} :as opts}]
|
[opts]
|
||||||
(let [props (opts->props opts)
|
(let [props (opts->props opts)]
|
||||||
session (Session/getInstance props)]
|
(Session/getInstance props)))
|
||||||
(.setDebug session debug)
|
|
||||||
session))
|
|
||||||
|
|
||||||
(defn- create-smtp-message
|
(defn- create-smtp-message
|
||||||
^MimeMessage
|
^MimeMessage
|
||||||
[cfg params]
|
[cfg session params]
|
||||||
(let [session (create-smtp-session cfg)
|
(let [mmsg (MimeMessage. ^Session session)]
|
||||||
mmsg (MimeMessage. ^Session session)]
|
|
||||||
(assign-recipients mmsg params)
|
(assign-recipients mmsg params)
|
||||||
(assign-from mmsg cfg params)
|
(assign-from mmsg cfg params)
|
||||||
(assign-reply-to mmsg cfg params)
|
(assign-reply-to mmsg cfg params)
|
||||||
|
@ -304,9 +301,16 @@
|
||||||
[_ cfg]
|
[_ cfg]
|
||||||
(fn [params]
|
(fn [params]
|
||||||
(when (contains? cf/flags :smtp)
|
(when (contains? cf/flags :smtp)
|
||||||
(Transport/send (create-smtp-message cfg params)
|
(let [session (create-smtp-session cfg)]
|
||||||
(:username cfg)
|
(with-open [transport (.getTransport session (if (:ssl cfg) "smtps" "smtp"))]
|
||||||
(:password cfg)))
|
(.connect ^Transport transport
|
||||||
|
^String (:username cfg)
|
||||||
|
^String (:password cfg))
|
||||||
|
|
||||||
|
(let [^MimeMessage message (create-smtp-message cfg session params)]
|
||||||
|
(.sendMessage ^Transport transport
|
||||||
|
^MimeMessage message
|
||||||
|
(.getAllRecipients message))))))
|
||||||
|
|
||||||
(when (or (contains? cf/flags :log-emails)
|
(when (or (contains? cf/flags :log-emails)
|
||||||
(not (contains? cf/flags :smtp)))
|
(not (contains? cf/flags :smtp)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue