diff --git a/backend/.env.template b/backend/.env.template index 5bbf65e3b..273ad7e64 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -5,8 +5,8 @@ GRAPHQL_PORT=4000 GRAPHQL_URI=http://localhost:4000 CLIENT_URI=http://localhost:3000 MOCKS=false -SMTP_HOST=localhost -SMTP_PORT=1025 +SMTP_HOST= +SMTP_PORT= SMTP_USERNAME= SMTP_PASSWORD= diff --git a/backend/README.md b/backend/README.md index 3cce123ac..cd56e231f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -44,6 +44,9 @@ or start the backend in production environment with: yarn run start ``` +For e-mail delivery, please configure at least `SMTP_HOST` and `SMTP_PORT` in +your `.env` configuration file. + Your backend is up and running at [http://localhost:4000/](http://localhost:4000/) This will start the GraphQL service \(by default on localhost:4000\) where you can issue GraphQL requests or access GraphQL Playground in the browser. diff --git a/backend/src/config/index.js b/backend/src/config/index.js index f0959ab53..e376c51e3 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -2,18 +2,18 @@ import dotenv from 'dotenv' dotenv.config() -export const requiredConfigs = { - MAPBOX_TOKEN: process.env.MAPBOX_TOKEN, - JWT_SECRET: process.env.JWT_SECRET, - PRIVATE_KEY_PASSPHRASE: process.env.PRIVATE_KEY_PASSPHRASE, -} +const { +MAPBOX_TOKEN, +JWT_SECRET, +PRIVATE_KEY_PASSPHRASE, +SMTP_HOST, +SMTP_PORT, +SMTP_USERNAME, +SMTP_PASSWORD, +} = process.env -export const smtpConfigs = { - SMTP_HOST: process.env.SMTP_HOST || 'localhost', - SMTP_PORT: process.env.SMTP_PORT || 1025, - SMTP_USERNAME: process.env.SMTP_USERNAME, - SMTP_PASSWORD: process.env.SMTP_PASSWORD, -} +export const requiredConfigs = { MAPBOX_TOKEN, JWT_SECRET, PRIVATE_KEY_PASSPHRASE } +export const smtpConfigs = { SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD } export const neo4jConfigs = { NEO4J_URI: process.env.NEO4J_URI || 'bolt://localhost:7687', @@ -28,7 +28,6 @@ export const serverConfigs = { } export const developmentConfigs = { - SEND_MAILS: process.env.SEND_MAILS || false, DEBUG: process.env.NODE_ENV !== 'production' && process.env.DEBUG === 'true', MOCKS: process.env.MOCKS === 'true', DISABLED_MIDDLEWARES: diff --git a/backend/src/schema/resolvers/passwordReset.js b/backend/src/schema/resolvers/passwordReset.js index ed9ec7ea1..baf6c1339 100644 --- a/backend/src/schema/resolvers/passwordReset.js +++ b/backend/src/schema/resolvers/passwordReset.js @@ -41,7 +41,7 @@ export default { requestPasswordReset: async (_, { email }, { driver }) => { const code = uuid().substring(0, 6) await createPasswordReset({ driver, code, email }) - if (CONFIG.SEND_MAILS) { + if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) { await transporter().sendMail({ from: '"Human Connection" ', // sender address to: email, // list of receivers