【发布时间】:2019-12-28 20:58:36
【问题描述】:
我正在尝试在我的 ionic 3 项目中实现 nodemailer,并按照 codeburst.io (https://codeburst.io/sending-an-email-using-nodemailer-gmail-7cfa0712a799) 的教程进行操作。
当我按照教程进行离子服务时,出现“找不到模块“dns”的错误。下图显示了我的控制台中的错误。
这是我的 .ts 文件中的代码:
constructor(){
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'XXXXX@gmail.com',
pass: 'XXXXXXXXXXXXXXX'
}
});
const mailOptions = {
from: 'XXXXXXX@email.com', // sender address
to: 'XXXXXXXXX@email.com', // list of receivers
subject: 'Subject of your email', // Subject line
html: '<p>Your html here</p>'// plain text body
};
transporter.sendMail(mailOptions, function (err, info) {
if(err)
console.log(err)
else
console.log(info);
});
}
我尝试过搜索,但找不到 Ionic 与 Angular 打字稿的解决方案。我对 DNS 的概念不熟悉,因此请提供一些指导/解释!
【问题讨论】:
标签: typescript ionic-framework ionic3 nodemailer