Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added EMAIL_FROM_ADDRESS environment variable. #456

Merged
merged 4 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ EMAIL_SERVER_URL: '' # DNS name of your smtp server
EMAIL_ACCESS_KEY: '' # User for the mail server
EMAIL_SECRET_KEY: '' # Password for the user
EMAIL_SERVER_PORT: 587 # Mail server port
EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to '[email protected]'
EMAIL_ERRORS_TO: '' # Email address that errors will be sent to
EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this.
EMAIL_TLS: 'false' # Should TLS be used?
DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database
ADMIN_PASSWORD: supersecretpassword #The datomic admin password (should be diffrent than the DATOMIC_PASSWORD)
DATOMIC_PASSWORD: yourpassword #The datomic application password
SIGNATURE: '<change me to something unique>' # The Secret used to hash your password in the browser, 20+ characters recommended
```

The `ADMIN_PASSWORD` and `DATOMIC_PASSWORD`
Expand Down Expand Up @@ -193,10 +196,13 @@ EMAIL_SERVER_URL: '' # Url to a smtp server
EMAIL_ACCESS_KEY: '' # User for the mail server
EMAIL_SECRET_KEY: '' # Password for the user
EMAIL_SERVER_PORT: 587 # Mail server port
EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to '[email protected]'
EMAIL_ERRORS_TO: '' # Email address that errors will be sent to
EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this.
DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database
ADMIN_PASSWORD: supersecretpassword
DATOMIC_PASSWORD: yourpassword
SIGNATURE: '<change me to something unique>' # The Secret used to hash your password in the browser, 20+ characters recommended
```

To change the datomic passwords you can do it through the environment variables `ADMIN_PASSWORD_OLD` and `DATOMIC_PASSWORD_OLD` start the container once, then set the `ADMIN_PASSWORD` and `DATOMIC_PASSWORD` to your new passwords.
Expand Down Expand Up @@ -462,4 +468,4 @@ The use of this tool is meant for use for your own use and your own content. It
Larry Christensen original author of [Orcpub2](https://github.com/larrychristensen/orcpub)

## License
[EPL-2.0](LICENSE)
[EPL-2.0](LICENSE)
4 changes: 4 additions & 0 deletions docker-compose-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ services:
EMAIL_ACCESS_KEY: ''
EMAIL_SECRET_KEY: ''
EMAIL_SERVER_PORT: 587
# Email address to send from, will default to '[email protected]'
EMAIL_FROM_ADDRESS: ''
# Email address to send errors to
EMAIL_ERRORS_TO: ''
EMAIL_SSL: 'TRUE'
EMAIL_TLS: 'FALSE'
# Datomic connection string - Make sure the <change this> matches the DATOMIC_PASSWORD below
DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=<change this>
# The secret used to hash your password in the browser, 20+ characters recommended
SIGNATURE: '<change me to something unique>'
depends_on:
- datomic
restart: always
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ services:
EMAIL_ACCESS_KEY: ''
EMAIL_SECRET_KEY: ''
EMAIL_SERVER_PORT: 587
# Email address to send from, will default to '[email protected]'
EMAIL_FROM_ADDRESS: ''
# Email address to send errors to
EMAIL_ERRORS_TO: ''
EMAIL_SSL: 'FALSE'
EMAIL_TLS: 'FALSE'
# Datomic connection string - Make sure the <change this> matches the DATOMIC_PASSWORD below
DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=<change this>
# The secret used to hash your password in the browser, 20+ characters recommended
SIGNATURE: '<change me to something unique>'
depends_on:
- datomic
restart: always
Expand Down
10 changes: 7 additions & 3 deletions src/clj/orcpub/email.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[postal.core :as postal]
[environ.core :as environ]
[clojure.pprint :as pprint]
[clojure.string :as s]
[orcpub.route-map :as routes]
[cuerdas.core :as str]))

Expand Down Expand Up @@ -35,9 +36,12 @@
:tls (or (str/to-bool (environ/env :email-tls)) nil)
})

(defn emailfrom []
(if (not (s/blank? (environ/env :email-from-address))) (environ/env :email-from-address) (str "[email protected]")))

(defn send-verification-email [base-url {:keys [email username first-and-last-name]} verification-key]
(postal/send-message (email-cfg)
{:from "OrcPub Team <[email protected]>"
{:from (str "OrcPub Team <" (emailfrom) ">")
:to email
:subject "OrcPub Email Verification"
:body (verification-email
Expand Down Expand Up @@ -70,7 +74,7 @@

(defn send-reset-email [base-url {:keys [email username first-and-last-name]} reset-key]
(postal/send-message (email-cfg)
{:from "OrcPub Team <[email protected]>"
{:from (str "OrcPub Team <" (emailfrom) ">")
:to email
:subject "OrcPub Password Reset"
:body (reset-password-email
Expand All @@ -80,7 +84,7 @@
(defn send-error-email [context exception]
(if (not-empty (environ/env :email-errors-to))
(postal/send-message (email-cfg)
{:from (str "OrcPub Errors <" (environ/env :email-errors-to) ">")
{:from (str "OrcPub Errors <" (emailfrom) ">")
:to (str (environ/env :email-errors-to))
:subject "Exception"
:body [{:type "text/plain"
Expand Down