在 meteor.js 中通过邮件从 html-form 传输数据

Transfer data from html-forms by mail in meteor.js

本文关键字:html-form 传输 数据 meteor js      更新时间:2023-09-26

如何在 meteor.js 中从电子邮件模板正文中的 html 表单传输数据?文档是一个示例:

Meteor.call('sendEmail', 'alice@example.com', 'bob@example.com', 'Hello from Meteor!', 'This is a test of Email.send.');

但它确实只传达字符串值的前进。如何从表单中传输数据?

你可以

做类似的事情

values = {
    nick: $('#nick').val(),
    message: $('#your-message').val()
}

并调用方法,例如

Meteor.call('sendEmail',
            'alice@example.com',
            'bob@example.com',
            'Hello from Meteor!',
            values); 

在服务器上的方法中

Meteor.methods({
  sendEmail: function (to, from, subject, text) {
    Email.send({
      to: to,
      from: from,
      subject: subject,
      text: 'Hello '+text.nick+'. Your message was: '+text.message
    });
  }
});