我的节点有settings.js,使用zoho电子邮件运行良好,我的nodejs应用程序能够使用zoho发送电子邮件,如下所示:
module.exports = {
mode: 'DEV',
dbConnectionString:'mongodb://eEvsXieSsW7FXrsw:F45we2opTa45sqD2D@67.217.104.22:60076/?authMechanism=SCRAM-SHA-1&authSource=goldRestaurant',
httpPort: 5081,
httpsPort: 5444,
httpsEnabled: true,
emailTransport: {
host: "smtp.zoho.com",
port: 465,
secure: true,
auth: {
user: "noreply@digiklug.com",
pass: "Digiklug5672"
},
tls: {
rejectUnauthorized: false
}
},
adminAppHost: "admin.dev.restaurant",
fromEmail: 'admin@digiklug.com.au',
ccEmailForDBError: ['info@digiklug.com'],
};
然而,当我将设置更改为gmail时,它失败了,错误如下:
/* jshint esversion: 6 */
module.exports = {
mode: 'QA',
dbConnectionString: 'mongodb://eEvsXieSsW7FXrsw:F95we2opTa45sqD2D@67.217.104.22:60076/?authMechanism=SCRAM-SHA-1&authSource=goldRestaurant',
httpPort: 81,
httpsPort: 8080,
httpsEnabled: true,
emailTransport: {
host: "smtp.gmail.com"
port: "465",
secure: "true",
auth: {
user: "contactzaika@gmail.com",
pass: "BZaika@123"
}
},
adminAppHost: "67.217.117.71:4200",
fromEmail: 'contactzaika@gmail.com',
ccEmail: ['azrat@digiklug.com', 'minaza@digiklug.com','admin@digiklug.com.au'],
ccEmailForDBError: ['admins@digiklug.com.au'],
toEmailForDBError: ['admins@digiklug.com.au']
};
我开始节点过程如下:
sudo nohup node /var/www/Zaika/restaurant_api/api_server/api_server.js --qa&
注意:从zoho到gmail的设置中唯一更改的内容如下:
host: "<>",
port: <>,
auth: {
user: "<>",
pass: "<>"
settings.js中的所有内容保持不变。
在更改为gmail后,节点进程甚至不会启动,nohup得到以下错误:
Calling getOnlineOrderMenu at 23-08-2022 03:50:32
Calling getPaymentStatus at 23-08-2022 03:50:32 for [object Object]
/var/www/Zaika/restaurant_api/api_server/settings.qa.js:13
port: 465,
^^^^
SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/var/www/Zaika/restaurant_api/api_server/settings.js:5:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
/var/www/Zaika/restaurant_api/api_server/settings.qa.js:13
port: "465",
^^^^
SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/var/www/Zaika/restaurant_api/api_server/settings.js:5:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
除了电子邮件SMTP设置外,没有任何更改。
你能建议我如何克服这个问题吗?
主机行末尾似乎缺少逗号:
原件:
emailTransport: {
host: "smtp.gmail.com"
port: "465",
secure: "true",
auth: {
user: "contactzaika@gmail.com",
pass: "BZaika@123"
}
},
添加了主机行逗号:
emailTransport: {
host: "smtp.gmail.com",
port: "465",
secure: "true",
auth: {
user: "contactzaika@gmail.com",
pass: "BZaika@123"
}
},
在添加逗号的情况下重试,看看调用现在是否有效。