Meteor电子邮件无法正常工作 - 错误:getaddrinfo ENOTFOUND

fuz*_*nny 4 meteor

我的meteor目前正在我的localhost上运行.

我添加了流星电子邮件包

meteor add email

server/server.js我添加(我的密码有很多特殊字符(@#$%^&),如果这有任何区别):

process.env.MAIL_URL="smtp://myusername%40gmail.com:mypassword@smtp.gmail.com:465/"; 
Run Code Online (Sandbox Code Playgroud)

然后在我添加的同一个文件中:

Email.send({
  from: "meteor.email.2014@gmail.com",
  to: "myusername@gmail.com",
  subject: "Meteor Can Send Emails via Gmail",
  text: "Its pretty easy to send emails via gmail."
});
Run Code Online (Sandbox Code Playgroud)

什么都没发送.我在Meteor控制台中得到了这个:

W20140607-11:37:24.449(8)? (STDERR) 
W20140607-11:37:24.452(8)? (STDERR) /home/wdi2p2/.meteor/tools/6f23056589/lib/node_modules/fibers/future.js:206
W20140607-11:37:24.453(8)? (STDERR)                         throw(ex);
W20140607-11:37:24.459(8)? (STDERR)                               ^
W20140607-11:37:24.466(8)? (STDERR) Error: getaddrinfo ENOTFOUND
W20140607-11:37:24.468(8)? (STDERR)     at Object.Future.wait (/home/wdi2p2/.meteor/tools/6f23056589/lib/node_modules/fibers/future.js:326:15)
W20140607-11:37:24.469(8)? (STDERR)     at smtpSend (packages/email/email.js:94)
W20140607-11:37:24.469(8)? (STDERR)     at Object.Email.send (packages/email/email.js:155)
W20140607-11:37:24.470(8)? (STDERR)     at app/server/server.js:3:7
W20140607-11:37:24.471(8)? (STDERR)     at app/server/server.js:10:3
W20140607-11:37:24.474(8)? (STDERR)     at /home/wdi2p2/Workspace/WDI/VLP/home-photo-pros/.meteor/local/build/programs/server/boot.js:155:10
W20140607-11:37:24.474(8)? (STDERR)     at Array.forEach (native)
W20140607-11:37:24.475(8)? (STDERR)     at Function._.each._.forEach (/home/wdi2p2/.meteor/tools/6f23056589/lib/node_modules/underscore/underscore.js:79:11)
W20140607-11:37:24.475(8)? (STDERR)     at /home/wdi2p2/Workspace/WDI/VLP/home-photo-pros/.meteor/local/build/programs/server/boot.js:82:5
W20140607-11:37:24.476(8)? (STDERR)     - - - - -
W20140607-11:37:24.477(8)? (STDERR)     at errnoException (dns.js:37:11)
W20140607-11:37:24.477(8)? (STDERR)     at Object.onanswer [as oncomplete] (dns.js:124:16)
=> Exited with code: 8
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

更新:

这是负责ENOTFOUND的代码

    it('times out on invalid host', function (done) {

        Sntp.time({ host: 'error', timeout: 10000 }, function (err, time) {

            expect(err).to.exist;
            expect(time).to.not.exist;
            expect(err.message).to.equal('getaddrinfo ENOTFOUND');
            done();
        });
    });
Run Code Online (Sandbox Code Playgroud)

所以我猜主机出于某种原因超时?

Aks*_*hat 12

getaddrinfo ENOTFOUND 通常是DNS错误(找不到地址)

可能是您的密码令域混淆.

你有@密码吗?尝试对其进行URL编码(仅限密码).

  • 我认为Meteor会自动为您做到这一点.试试这个`process.env.MAIL_URL ="smtp://myusername%40gmail.com:'+ encodeURIComponent(<你的密码在这里>)+"@ smtp.gmail.com:465"` (3认同)