0

Node.js + Express + Nodemailer アプリをテストしたいです。

エラーを生成できますか?

smtpTransport.sendMail(mailOptions, function(error, response){
    if(error){
        console.log(error);

        res.contentType('json');
        res.writeHead(500, { 'Content-Type': 'application/json'});
        res.write(JSON.stringify({ success: false, message: error }));
        res.end();
    }else{
        console.log("Message sent: " + response.message);

        res.contentType('json');
        res.writeHead(200, { 'Content-Type': 'application/json'});
        res.write(JSON.stringify({ success: true, message: response.message }));
        res.end();
    }

});
4

1 に答える 1

1

それはすべて、受信しようとしているエラーの種類によって異なります。

以下にいくつかの提案を示します。

  1. メールを送信するアカウントの mailOptions オブジェクトに間違ったパスワードを入力してください。これにより、何らかの認証エラーが発生します。

  2. このコードが実行される前に、インターネット接続を切断してください。node-inspector を使用してサーバー コードにブレークポイントを挿入し、再開する前に実行を停止してネットワークから切断することができます。


node-inspector をインストールするには:

npm install -g node-inspector

次に実行します

node-debug app.js


お役に立てれば!

于 2014-12-17T18:23:31.527 に答える