Для Метеора 1.0.5 используйте
Template.<yourTemplate>.onCreated(function() { ... })
вместо
Template.<yourTemplate>.created = ...
на шаге 4 Meteor #20: проверка электронной почты с учетными записями Meteor.
Демонстрация ниже отлично работает под Meteor 1.0.5.
проверитьEmail.html:
<head>
<title>Verify Email</title>
</head>
<body>
<h1>Sending Email Demo</h1>
{{> loginButtons}}
</body>
verifyEmail.js: (замените имя пользователя, пароль и значение сервера для вашего случая)
if (Meteor.isClient) {
Template.SendAnyEmail.onCreated(function() {
if (Accounts._verifyEmailToken) {
Accounts.verifyEmail(Accounts._verifyEmailToken, function(err) {
if (err != null) {
if (err.message = 'Verify email link expired [403]') {
console.log('Sorry this verification link has expired.')
}
} else {
console.log('Thank you! Your email address has been confirmed.')
}
});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
smtp = {
username: '[email protected]',
password: 'password',
server: 'mail.example.com',
port: 465
};
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
Accounts.emailTemplates = {
from: 'Administrator <[email protected]>',
siteName: 'YourSite',
verifyEmail: {
subject: function(user) {
return 'Verification email from Example.com';
},
text: function(user, url) {
return 'Hi,\n' +
'Please open the link below to verify your account on Example.com:\n' + url;
}
}
};
});
Accounts.onCreateUser(function(options, user) {
Meteor.setTimeout(function() {
Accounts.sendVerificationEmail(user._id);
}, 2 * 1000);
return user;
});
}
30.03.2015