我正在关注Meteor in Action一书,我正在制作一个简单的应用程序,要求SMTP服务器在注册时发送电子邮件验证。
我遵循了所有步骤,但似乎有些不对劲。正在创建用户,但未发送验证邮件,事实上,正在抛出错误:
I20150128-16:16:53.221(5.5)? Exception in setTimeout callback: Error: connect ETIMEDOUT
I20150128-16:16:53.225(5.5)? at Object.Future.wait (/Users/niranjan/.meteor/packages/meteor-tool/.1.0.40.i0mc94++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:326:15)
I20150128-16:16:53.225(5.5)? at smtpSend (packages/email/email.js:91:1)
I20150128-16:16:53.226(5.5)? at Object.Email.send (packages/email/email.js:168:1)
I20150128-16:16:53.226(5.5)? at Object.Accounts.sendVerificationEmail (packages/accounts-password/password_server.js:602:1)
I20150128-16:16:53.226(5.5)? at app/server/server.js:10:16
I20150128-16:16:53.227(5.5)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150128-16:16:53.227(5.5)? at packages/meteor/timers.js:6:1
I20150128-16:16:53.227(5.5)? at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
I20150128-16:16:53.227(5.5)? - - - - -
I20150128-16:16:53.227(5.5)? at errnoException (net.js:904:11)
I20150128-16:16:53.228(5.5)? at Object.afterConnect [as oncomplete] (net.js:895:19)
我一直试图调试这个,但似乎无法弄清楚发生了什么。
以下是相关代码 - client / templates.html:
Accounts.onCreateUser(function (options, user) {
if (options.profile) {
user.profile = options.profile;
} else {
user.profile = "White belt";
}
user.profile.rank = "White belt";
if(options.email) {
Meteor.setTimeout(function () {
Accounts.sendVerificationEmail(user._id); // I think this is the error source
}, 2 * 1000 );
}
return user;
});
server / smtp.js:
Meteor.startup(function () {
smtp = {
username: 'myemail@gmail.com',
password: 'mysecretpassword',
servre: 'smtp.gmail.com',
port: 587
};
process.env.MAIL_URL = 'smtp://' +
encodeURIComponent(smtp.username) + ':' +
encodeURIComponent(smtp.password) + '@' +
encodeURIComponent(smtp.server) + ':' +
smtp.port;
});
Accounts.emailTemplates.siteName = "Meteor in Action userApp";
Accounts.emailTemplates.from = "Name <myemail@gmail.com>";
Accounts.emailTemplates.verifyEmail.subject = function (user) {
return 'Confirm your email address, ' + user.username;
};
Accounts.emailTemplates.verifyEmail.text = function (user, url) {
return 'Welcome to the Meteor in Action userApp! \n'
+ 'To veryify - \n' + url;
};
Accounts.emailTemplates.verifyEmail.html = function (user, url) {
return "<h1>Welcome to the Meteor in Action userApp! </h1>"
+ "<p>To verify - </p>" + url;
};
答案 0 :(得分:1)
问题,我的朋友,在server/smtp.js
文件中,你拼错了世界服务器。因此smtp对象没有任何名为server
的属性。您定义为servre
。