Meteor电子邮件未定义,但正在从Meteor.methods运行

bla*_*neh 7 meteor

我有以下Meteor方法设置:

// Defined in collections/collections.js
Meteor.methods({
    email: function(options) {
        this.unblock();
        Email.send(options);
    }
});
Run Code Online (Sandbox Code Playgroud)

我称之为:

// Defined in client/main.js
Meteor.call('email', {
    to: 'yeahright@noneya.com', from: 'yeahright@noneya.com',
    text: 'testing testing'
});
Run Code Online (Sandbox Code Playgroud)

我在浏览器控制台中收到两个错误:

Exception while simulating the effect of invoking 'email' 
ReferenceError {stack: "ReferenceError: Email is not defined?    at Meteor…js?acc2397bd1f7321a583a30e0d4628ec4f9fded4b:369:3", message: "Email is not defined"}
 ReferenceError: Email is not defined
(etc....)
Run Code Online (Sandbox Code Playgroud)

另一个在我的服务器shell中运行meteor:

Exception while invoking method 'email' ReferenceError: Email is not defined
(etc....)
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?我觉得我已经按照文件的指示准确,我什么也没做类似的错误在这样的问题这一个这一个.

mb.*_*mb. 6

你添加了电子邮件包吗?

meteor add email
Run Code Online (Sandbox Code Playgroud)


132*_*941 5

正如paul所说,看起来错误就是你试图Email.send()从客户端打电话.

Email.send()只能在服务器上调用.要解决此问题,请尝试将方法定义移至服务器.

Email.send()