Nodemailer Bluemix错误

时间:2018-01-09 18:31:23

标签: node.js ibm-cloud nodemailer

当我尝试在本地使用nodemailer时,它工作正常。但是当我将代码上传到IBM Bluemix并尝试发送简单邮件时,它会返回以下错误:

2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR _http_outgoing.js:654
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument',
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     ^
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at write_ (_http_outgoing.js:654:11)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at ServerResponse.write (_http_outgoing.js:629:10)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at writetop (/home/vcap/app/node_modules/express-session/index.js:296:22)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at ServerResponse.end (/home/vcap/app/node_modules/express-session/index.js:338:16)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at sendMail (/home/vcap/app/routes/nav.js:419:24)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at transporter.sendMail (/home/vcap/app/mailer.js:23:25)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at transporter.send.args (/home/vcap/app/node_modules/nodemailer/lib/mailer/index.js:224:21)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at SMTPConnection.connection.once.err (/home/vcap/app/node_modules/nodemailer/lib/smtp-transport/index.js:174:24)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at Object.onceWrapper (events.js:254:19)
   2018-01-09T15:32:30.86-0200 [APP/PROC/WEB/0] ERR     at SMTPConnection.emit (events.js:159:13)
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR! errno 1
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR! proxxi_forms@1.0.0 start: `node server.js`
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR! Exit status 1
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR!
   2018-01-09T15:32:30.87-0200 [APP/PROC/WEB/0] ERR npm ERR! Failed at the proxxi_forms@1.0.0 start script.
   2018-01-09T15:32:30.88-0200 [APP/PROC/WEB/0] ERR npm ERR! This is probably not a problem with npm. There is likely additional logging output above

我为nodemailer提供了以下配置:

const nodemailer = require('nodemailer');
const config = require('./config').get(process.env.NODE_ENV);

const transporter = nodemailer.createTransport({
    host: config.NODEMAILER.HOST,
    port: 25,
    secure: false,
});

const sendMail = (options, cb) => {
    if (!options.from) options.from = config.NODEMAILER.EMAIL;
    transporter.sendMail(options, (err, info) => {
        if (err) return cb(err);
        cb(null, info);
    });
};

module.exports = {sendMail};

本地和Bluemix内部使用的Node和npm版本是相同的:

节点版本:9.3.0

npm版本:5.5.1

nodemailer version:4.4.1

如果有人对此错误有所了解,请分享!

0 个答案:

没有答案