【问题标题】:Meteor email success alertMeteor 电子邮件成功警报
【发布时间】:2017-05-05 11:29:32
【问题描述】:

我正在使用 Bert 和 Meteor 电子邮件。在我的 MEteor 方法中,我返回发送电子邮件的成功。问题是,发送电子邮件后,它没有返回成功消息。

这是我的示例代码,

Meteor.call('sendEmail',
                data.eadd,
                'e@gmail.com',
                'Invitation',
                'test');

            return "successful.";

这是我的 sendEmail 函数,

sendEmail(to, from, subject, text) {
    check([to, from, subject, text], [String]);
    this.unblock();
    Email.send({
        to: to,
        from: from,
        subject: subject,
        text: text
    });
}

【问题讨论】:

标签: javascript email meteor bert-rpc


【解决方案1】:

您的Meteor.call() 需要包含一个回调,并且您的sendEmail 函数需要返回一个值。重新排列代码如下:

Meteor.call('sendEmail',data.eadd,'e@gmail.com','Invitation','test',(err,result)=>{
  if (err) Bert.alert({ title: 'Error sending email: '+err, type: 'danger' });
  else Bert.alert({ title: 'Email sent!', type: 'success' })
});

sendEmail(to, from, subject, text) {
  check([to, from, subject, text], [String]);
  this.unblock();
  Email.send({
    to: to,
    from: from,
    subject: subject,
    text: text
  });
  return "successful.";  
}

注意: 从安全角度来看,我不推荐这种可以在客户端上指定整个电子邮件的方法,因为您基本上已经创建了一个可编写脚本的开放式电子邮件中继 - 甚至可以由匿名用户运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多