4 Commits

Author SHA1 Message Date
Andros Fenollosa
46344044e9 Fixbug subject 2020-06-11 19:47:56 +02:00
Andros Fenollosa
da0d8c07ca Add domain cli 2020-06-11 19:39:38 +02:00
Andros Fenollosa
0e5e981e79 Fix CORS post 2020-06-11 19:14:12 +02:00
Andros Fenollosa
81d0b9e947 Update config file 2020-06-11 19:09:13 +02:00
4 changed files with 14 additions and 11 deletions

View File

@@ -1,9 +1,12 @@
domain: "http://localhost"
domain: "domain.com"
domain-cli: "domain.com"
debug: true
port: 7404
smtp-from: "api2smtp <no-reply@www.tadam-framework.dev>"
smtp-host: localhost
smtp-user:
smtp-pass:
smtp-tls: false
smtp-port: 1025
smtp-from: "no-reply@domain.com"
smtp-to: "my@domain.com"
smtp-subject: "Contact"
smtp-host: "smtp.domain.com"
smtp-user: ""
smtp-password: ""
smtp-port: 587
smtp-tls: true

View File

@@ -1,4 +1,4 @@
(defproject api2smtp "1.0.2"
(defproject api2smtp "1.0.5"
:description "Send emails through an Endpoint API"
:url "https://github.com/tanrax/api2smtp"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"

View File

@@ -12,8 +12,8 @@
(-> all-routes
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
(wrap-cors
:access-control-allow-origin [(re-pattern (if (config :debug) ".*" (config :domain)))]
:access-control-allow-methods [:get])
:access-control-allow-origin [(re-pattern (if (config :debug) ".*" (config :domain-cli)))]
:access-control-allow-methods [:get :post])
(#(if (config :debug) (wrap-reload %) %))))
(defn -main [& args]

View File

@@ -16,7 +16,7 @@
:email (-> json :email)
:message (-> json :message)}]
;; Send email
(send config (:smtp-to config) (:smtp-to config) (render-template "emails/contact.html" params) (render-template "emails/contact.txt" params))
(send config (:smtp-to config) (:smtp-subject config) (render-template "emails/contact.html" params) (render-template "emails/contact.txt" params))
;; Response OK
(render-JSON req {:status "ok"})))