Skip to content

Commit cc8fd5d

Browse files
committed
Add mailhog for email debugging, set mailer config with environment variables, predefine mailer environment variables in docker
1 parent 913d487 commit cc8fd5d

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

core/mailer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ let nodeMailer = require('nodemailer'),
88
function initTransporter(){
99
if(transporter === undefined){
1010
transporter = nodeMailer.createTransport({
11-
host: '',
12-
port: 25,
11+
host: process.env.MAIL_HOST || 'localhost',
12+
port: process.env.MAIL_PORT || 25,
1313
secure: false,
1414
auth: {
15-
user: '',
16-
pass: ''
15+
user: process.env.MAIL_USER || '',
16+
pass: process.env.MAIL_PASS || ''
1717
}
1818
});
1919
}
@@ -65,4 +65,4 @@ exports.sendVerificationMail = function(key, recipient, callback = null){
6565
});
6666
}
6767
});
68-
};
68+
};

docker-compose.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ services:
99
ports:
1010
- 3306:3306
1111

12+
mailhog:
13+
container_name: mailhog
14+
image: mailhog/mailhog
15+
ports:
16+
- 1025:1025
17+
- 8025:8025
18+
1219
coc-api:
1320
image: clock-of-change-api
1421
build:
@@ -23,7 +30,11 @@ services:
2330
- MYSQL_DB=clock_of_change
2431
- MYSQL_USER=root
2532
- MYSQL_PASS=123456
33+
- MAIL_HOST=mailhog
34+
- MAIL_PORT=1025
35+
- MAIL_USER=mailer
36+
- MAIL_PASS=123456
2637
depends_on:
2738
- db
39+
- mailhog
2840
command: bash -c "sleep 5 && db-migrate up && npm run start"
29-
#entrypoint: /docker-entrypoint.sh

0 commit comments

Comments
 (0)