我正在尝试使用nodemailer设置strapi应用程序。
我已经添加了nodemailer依赖与yarn add @strapi/provider-email-nodemailer
在官方页面上描述。之后,我将以下配置添加到plugins.js
文件中(我已将敏感信息替换为XXXXXXXX
):
module.exports = ({ env }) => ({
email: {
config: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'XXXXXXXX'),
port: env('SMTP_PORT', 587),
auth: {
user: env('SMTP_USERNAME', 'XXXXXXXX'),
pass: env('SMTP_PASSWORD', 'XXXXXXXX'),
},
secure: true
},
settings: {
defaultFrom: 'XXXXXXXX',
defaultReplyTo: 'XXXXXXXX',
},
},
},
});
但是当我尝试用yarn develop
绑定Strapi时,我得到以下错误消息:
C:\Dev\Strapi\Projects\strapi>yarn develop
yarn run v1.22.15
$ strapi develop
Building your admin UI with development configuration ...
Admin UI built successfully
[2021-12-27 23:27:51.485] debug: ⛔️ Server wasn't able to start properly.
[2021-12-27 23:27:51.487] error: Could not load email provider "nodemailer".
Error: Could not load email provider "nodemailer".
at createProvider (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\plugin-email\server\bootstrap.js:23:11)
at Object.module.exports [as bootstrap] (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\plugin-email\server\bootstrap.js:31:37)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\core\domain\module\index.js:40:47)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\core\registries\modules.js:28:19)
at async Strapi.runLifecyclesFunctions (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\Strapi.js:463:5)
at async Strapi.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\Strapi.js:401:5)
at async Strapi.load (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\Strapi.js:410:5)
at async Strapi.start (C:\Dev\Strapi\Projects\strapi\node_modules\@strapi\strapi\lib\Strapi.js:161:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我做错了什么?配置看起来很简单,所以我不知道出了什么问题。
2条答案
按热度按时间hc2pp10m1#
你应该安装
并将其添加到您的发送电子邮件服务中:
这将发送一封邮件。
cyej8jka2#
您需要删除配置部分:
UPD:对不起,我现在明白了,我使用这个软件包https://www.npmjs.com/package/strapi-provider-email-nodemailer,你使用这个https://www.npmjs.com/package/@strapi/provider-email-nodemailer