0

次のようなメール送信を設定しました。

        nodemailer = require("nodemailer");
...
            nodemailer.SMTP = {
                host: 'smtp.gmail.com', // required
                port: 465, // optional, defaults to 25 or 465
                domain: 'smtp.gmail.com', // domain used by client to identify itself to server
                authentication: 'login', // optional, false by default
                user: '1*******@gmail.com', // used only when use_authentication is true
                pass: '*******'  // used only when use_authentication is true
            }

            // send an e-mail
            nodemailer.send_mail(
                // e-mail options
                {
                    sender: '1*******@gmail.com',
                    to:'2*******@gmail.com',
                    subject:'Hello!',
                    html: '<p><b>Hi,</b> how are you doing?</p>',
                    body:'Hi, how are you doing?'
                },
                // callback function
                function(error, success){
                    console.log('Message ' + success ? 'sent' : 'failed');
                }

コールバック関数は「送信済み」をログに記録しますが、電子メールは配信されません。このチュートリアルに従いましたhttp://www.thihaz.com/?p=218

追加でセットアップする必要がありますか?

4

1 に答える 1

2

nodemailer対応するサーバー (Gmail など) の処理を​​任せることができます。

var smtpTransport = nodemailer.createTransport("SMTP",{
    auth: {
        user: "gmail.user@gmail.com", // service is detected from the username
        pass: "userpass"
    }
});

そして、次のようにします。

transport.sendMail()

これで正しい道に進むはずです。

于 2014-06-19T21:21:21.220 に答える