我正在使用accounts-base / accounts-password,不使用accounts.ui软件包来创建帐户。我在server
端有一个代码
Accounts.config({
sendVerificationEmail: true,
forbidClientAccountCreation: true // cause we call it from server code
});
然后稍后在注册表单上提交我致电
Accounts.createUser({User account document where `email` field is set to actual email});
它创建了用户(以后我可以用该用户登录),没有任何问题或错误,但它不会向我发送任何电子邮件。
我已安装流星电子邮件程序包,但未配置电子邮件URL,因此它应该在不会出现的标准输出中打印消息。
我可以使用后期用户创建钩子并手动发送电子邮件,但是我认为它应该可以工作,而无需进行文档中所述的额外工作。
流星版本为1.0.3.1
我也面临相同的问题,但是它可以在我拥有的其他项目中使用。有一种使用钩子(https://github.com/Meteor-Community-Packages/meteor-collection-hooks)的解决方法。
用meteor add matb33:collection-hooks
添加软件包
然后将其导入服务器端import { CollectionHooks } from 'meteor/matb33:collection-hooks';
最后,在您的Meteor.starup中,可以添加以下代码:
Meteor.users.after.insert((userId, doc) => {
Accounts.sendVerificationEmail(doc._id);
});
我也尝试过在Accounts.onCreateUser上发送电子邮件验证,但是似乎该用户尚未存储在数据库中,因此失败。
使用流星1.8.3。
UPDATE:阅读代码后,我发现sendVerificationEmail仅在用户在客户端注册时才有效(这不是您的情况,也不是我的情况,因为我们俩都禁止这样做)。
您可以检查account_commons.js并检查是否对此有评论:
// - sendVerificationEmail {Boolean}
// Send email address verification emails to new users created from
// client signups.
现在您可以继续使用钩子了。