![](/img/trans.png)
[英]Meteor: Accounts.sendVerificationEmail customising behavior
[英]Accounts.sendVerificationEmail Issue in Meteor
我需要使用Meteor
发送VerificationEmail。我做了代码,但没有发送VerificationEmail,并且在服务器端也出现了错误。错误是: 找不到用户 。对此我一无所知。所以请参阅下面的代码并建议我该怎么做。
JS代码:
if (Meteor.isClient)
{
Template.main.events
({
'submit #register-form' : function (e,t)
{
console.log("You pressed the button Register ");
e.preventDefault();
var username = t.find('#username').value
, name = t.find('#name').value
, email = t.find('#email1').value
, password = t.find('#pwd1').value;
console.log("password="+password);
var isValidPassword = function(val, field)
{
if (val.length >= 6) {
return true;
} else {
Session.set('displayMessage', 'Error & Too short.')
return false;
}
}
if (isValidPassword(password))
{
console.log(" *** isValidPassword *** ");
Accounts.createUser({email: email, password : password,username : username }, function(err)
{
if (err)
{
console.log(err);
}
else
{
console.log("Register Successfully");
Meteor.call('sendEmail',
'*****@gmail.com',
'****.com',
'Hello from Meteor!',
'This is a test of Email.send.');
}
});
}
else
{
console.log("*** Error ***");
}
}
});
}
if (Meteor.isServer)
{
Meteor.startup(function ()
{
// code to run on server at startup
});
//Meteor methods
Meteor.methods
({
sendEmail: function (to, from, subject, text)
{
Accounts.config({sendVerificationEmail: true, forbidClientAccountCreation: false});
process.env.MAIL_URL = 'smtp://****@gmail.com:*pwd*@smtp.gmail.com:587';
this.unblock();
Accounts.sendVerificationEmail(to);
}
});
}
您是否已将电子邮件发送到电子邮件地址? 当您在Accounts.sendVerificationEmail(to);
使用to
时Accounts.sendVerificationEmail(to);
它必须是您要将确认电子邮件发送到的用户的_id
,而不是他们的电子邮件地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.