Kaynağa Gözat

Use the built-in smtp transport to send mail

Girish Ramakrishnan 7 yıl önce
ebeveyn
işleme
615dcc8059
3 değiştirilmiş dosya ile 10 ekleme ve 8 silme
  1. 0 1
      Dockerfile
  2. 7 4
      start.sh
  3. 3 3
      test/test.js

+ 0 - 1
Dockerfile

@@ -10,7 +10,6 @@ RUN curl -L https://github.com/NodeBB/NodeBB/archive/v1.7.5.tar.gz | tar -xz --s
 ADD config.json.template /app/code
 RUN cp /app/code/install/package.json /app/code/package.json
 RUN npm install --production
-RUN npm install nodebb-plugin-emailer-local
 
 RUN mv /app/code/node_modules /app/code/node_modules_copy && ln -s /run/nodebb/node_modules /app/code/node_modules && \
 	mv /app/code/public /app/code/public_template && ln -s /run/nodebb/public /app/code/public && \

+ 7 - 4
start.sh

@@ -77,10 +77,13 @@ for plugin in $(./nodebb plugins | grep 'nodebb-' | cut -f3 -d' '); do
     fi
 done
 
-echo "=> Enabling the local mailer"
-${mongo_cli} --eval "db.objects.update({ _key: \"settings:emailer-local\" }, { \$set: { \"host\": \"${MAIL_SMTP_SERVER}\", \"port\": \"${MAIL_SMTP_PORT}\", \"username\": \"${MAIL_SMTP_USERNAME}\", \"password\": \"${MAIL_SMTP_PASSWORD}\", \"secure\": \"off\" } }, { upsert: true })"
-${mongo_cli} --eval "db.objects.update({ _key: \"config\" }, { \$set: { \"email:from\": \"${MAIL_FROM}\", \"email:from_name\": \"NodeBB\" } }, { upsert: true })"
-${mongo_cli} --eval "db.objects.update({ _key: \"plugins:active\" }, { \$set: { \"value\": \"nodebb-plugin-emailer-local\", \"score\": \"0\" } }, { upsert: true })"
+# setup email
+## remove legacy emailer-local plugin settings
+${mongo_cli} --eval "db.objects.remove({ _key: 'settings:emailer-local' })"
+${mongo_cli} --eval "db.objects.remove({ _key: 'plugins:active', value: 'nodebb-plugin-emailer-local' })"
+
+echo "Setting up email"
+${mongo_cli} --eval "db.objects.update({ _key: 'config' }, { \$set: { 'email:smtpTransport:enabled': '1', 'email:smtpTransport:service': 'nodebb-custom-smtp', 'email:smtpTransport:host': '${MAIL_SMTP_SERVER}', 'email:smtpTransport:port': '${MAIL_SMTP_PORT}', 'smtpTransport': '${MAIL_SMTP_USERNAME}', 'email:smtpTransport:pass': '${MAIL_SMTP_PASSWORD}', 'email:smtpTransport:security': 'NONE', 'email:from': '${MAIL_FROM}' } }, { upsert: true })"
 
 # there are 3 binaries
 # nodebb - this is used for controlling nodebb (start/stop/restart) etc

+ 3 - 3
test/test.js

@@ -70,12 +70,12 @@ describe('Application life cycle test', function () {
     }
 
     function checkMailPlugin(done) {
-        browser.get('https://' + app.fqdn + '/admin/emailers/local').then(function () {
-            return browser.wait(until.elementLocated(by.id('host')), TEST_TIMEOUT);
+        browser.get('https://' + app.fqdn + '/admin/settings/email').then(function () {
+            return browser.wait(until.elementLocated(by.id('email:smtpTransport:host')), TEST_TIMEOUT);
         }).then(function () {
             return browser.sleep(10000);
         }).then(function () {
-            return browser.findElement(by.id('host')).getAttribute('value');
+            return browser.findElement(by.id('email:smtpTransport:host')).getAttribute('value');
         }).then(function (val) {
             if (val !== 'mail') return done(new Error('Incorrect mail server value: ' + val));
             done();