Meteor Error Sending Accounts Emails


I’m trying to setup various account-related functionality like sending verification emails and password reset emails.

I have signed up with SendGrid and added my MAIL_URL config. This appears to be working as I can send an email using Email.send(…).

However, whenever I try to use the Accounts functions, I get an error:

Exception while invoking method 'users.sendVerificationEmail' Error: After filtering out keys not in the schema, your modifier is now empty.

This is happening on the client side (using Accounts.forgotPassword) and server side (using Accounts.sendVerificationEmail). I think it might be something related to my users schema but I have no idea what.

This is my users schema:

UserSchema = new SimpleSchema(
    username: { type: String, required: true },
    services: Object,
    'services.password': Object,
    'services.password.bcrypt': String,
    'services.resume': { type: Object, blackbox: true },
    emails: { type: Array, label: "Email Addresses" },
    'emails.$': Object,
    'emails.$.address': String,
    'emails.$.verified': Boolean,
    createdAt: Date,
    profile: { type: Object, blackbox: true },
  { tracker: Tracker, requiredByDefault: false }

This is my server side method:

"users.sendVerificationEmail": async (userId) => {
    if(Meteor.isServer) {

The userId parameter is being filled correctly (i.e. it’s not undefined or anything) - the console.log shows the id.

The full error stack trace is:

Exception while invoking method 'users.sendVerificationEmail' Error: After filtering out keys not in the schema, your modifier is now empty
I20201112-08:53:42.104(0)?     at doValidate (packages/aldeed:collection2/collection2.js:432:11)
I20201112-08:53:42.104(0)?     at Collection.Mongo.Collection.<computed> [as update] (packages/aldeed:collection2/collection2.js:200:14)
I20201112-08:53:42.104(0)?     at AccountsServer.Accounts.generateVerificationToken (packages/accounts-password/password_server.js:705:16)
I20201112-08:53:42.104(0)?     at AccountsServer.Accounts.sendVerificationEmail (packages/accounts-password/password_server.js:914:14)
I20201112-08:53:42.104(0)?     at imports/db/users/methods.js:51:16

What am I missing?

I’d suggest you detach the schema from the users collection and try again. If all ok, re-attach the schema and narrow down by blackboxing all objects.
I see for instance that I do not add services to my user schema. Ok, I have no science behind this thinking but there are parts of the User object that cannot be altered or verified with a schema because they are “by default” provided by Meteor. For instance, your 'services.password' can only be an object, can never be optional etc…

1 Like

Okay, thank you @paulishca ! I will try that.

I did wonder if there were differences in how the User schema is handled compared to all other collections.

For some reason, I thought I had to explicitly add all fields. It will also make the schema code cleaner if I remove fields like that.

I managed to fix this so I thought I’d come back and answer in case anyone else hits the same issue in future.

I think I solved it by changing the services field to use blackbox:

services: { type: Object, blackbox: true }

I also remember having issues because I had not explicitly set the email address that I was meant to be sending emails from. I.e. the email address configured in SendGrid.

So I added this line on server startup:

Accounts.emailTemplates.from = '';

(Replace with your email address).

I don’t think this was directly related to this error, but it did block me for a while.