[英]Meteor accounts Email Verification
如何使用自定义消息和自定义from参数(而不是默认参数)向用户发送电子邮件验证。
Meteor.methods({
sendveryficationmail: function (theuserId, themail) {
this.unblock();
Accounts.sendVerificationEmail(theuserId);
}
});
当我使用该方法时,会收到默认的流星验证电子邮件。 如何更改参数以及应从何处更改参数?
您可以创建自己的函数以使用模板发送自定义HTML,也可以将简单HTML事件传递给模板文件而不是模板。 这是代码:
'sendVerificationEmail':function (emailId) {
Meteor.users.update({'emails.address': emailId}, {$unset: {'services.email.verificationTokens': 1}});
var user = Meteor.users.findOne({"emails.address": emailId});
if (user) {
if( user.emails.find(email=> email.address === emailId ).verified ){
throw new Meteor.Error("Email already verified");
} else {
var userInfo = user.profile;
var emailId = user.email[0].address;
Accounts.emailTemplates.siteName = "NJAL";
Accounts.emailTemplates.from = "myTest <community@myTest.com>";
Accounts.emailTemplates.verifyEmail.subject = function(user) {
return "Account Verification Required";
};
Accounts.emailTemplates.verifyEmail.html = function (user, url) {
SSR.compileTemplate( 'registartionEmail', Assets.getText( 'email_templates/registration_confirm.html' ) );
var res=url.split("/");
var emailData = {
"designer_name": userInfo.fname + " "+ userInfo.lname,
"url": "http://domain.com/pages/verify/?token="+res[res.length-2]+"/"+res[res.length-1],
"emailId": emailId,
};
return SSR.render( 'registartionEmail', emailData );
};
Accounts.sendVerificationEmail(user._id, emailId);
}
} else {
throw new Meteor.Error("Email does not exist");
}
},
您可以这样做:
Meteor.startup(function() {
Accounts.verifyEmail = {
from: 'custom from',
subject: 'your subject',
text: 'Your text',
html: 'Your html'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.