diff --git a/.gitignore b/.gitignore index 3c3629e..37d7e73 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.env diff --git a/Dockerfile b/Dockerfile index 374ff89..1b7477e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,6 @@ RUN haraka -i /app RUN echo webmailer >> /app/config/plugins RUN echo "listen=[::0]:8080" >> /app/config/http.ini RUN echo "listen=[::0]:2525" >> /app/config/smtp.ini -COPY testing/testTemplate.js /app/plugins/webmailer/templates/testTemplate.js +COPY testing/testTemplate.js /app/templates +COPY . /app/plugins/webmailer CMD haraka -c /app diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f0fdd10 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3' + +services: + mail: + env_file: + - .env + build: + context: . + ports: + - '8080:8080' + - '2525:2525' + volumes: + - ./:/app/plugins/webmailer diff --git a/index.js b/index.js index 372cdbb..cb99d98 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,18 @@ let fs = require('fs'); let bodyParser = require('body-parser'); let outbound; - -let getTemplates = require('./templates'); +let getTemplates; let errorSender = require('./errorSender'); exports.register = function() { outbound = this.haraka_require('./outbound'); + try { + getTemplates = this.haraka_require('./templates'); + if(!getTemplates || !Object.keys(getTemplates).length) { + throw Error ("No templates loaded!"); + } + }catch(e) { + this.logerror("No email templates were loaded! Please add a templates directory with templates and try agin"); + } this.register_hook('init_http', 'initExpress'); } diff --git a/templates/testTemplate.js b/templates/testTemplate.js new file mode 120000 index 0000000..da82b7d --- /dev/null +++ b/templates/testTemplate.js @@ -0,0 +1 @@ +../testing/testTemplate.js \ No newline at end of file