Nodemailer-Sendmail传输器错误:TypeError:this._spawn不是函数

时间:2019-03-20 13:33:13

标签: node.js reactjs sendmail nodemailer

online guide of Nodemailer之后并使用package,我在React项目中创建了一个基本的sendmail传输器,如下所示:

handleSubmit(event) {
        event.preventDefault();
        console.log("ok")
        let transporter = nodemailer.createTransport({"sendmail": true});
        transporter.sendMail({
            from: '"Firstname Lastname" <me@example.com>', // sender address
            to: "me@example.com", // list of receivers
            subject: "Hello", // Subject line
            html: "<b>My mail from React!</b>" // html body
        });
}

但是,当单击“提交”按钮时,出现以下错误:

  

TypeError:this._spawn不是函数

现在有人为什么会出现此问题吗?每当我找到有关sendmail的其他示例时,它们都像上面一样半精确。

错误代码

位置:
node_modules / nodemailer / lib / sendmail-transport / index.js

代码块

try {
    sendmail = this._spawn(this.path, args);  <<<<<<<<<<<< This is where the error occurs <<<<<<<<<<<<
} catch (E) {
    this.logger.error(
        {
            err: E,
            tnx: 'spawn',
            messageId
        },
        'Error occurred while spawning sendmail. %s',
        E.message
    );
    return callback(E);
}

0 个答案:

没有答案