MeteorJS如何设置"来自"帐户电子邮件的字段,例如验证电子邮件/重置密码

时间:2015-12-27 21:22:03

标签: meteor mandrill

我正在尝试发送"验证电子邮件"来自我部署的流星应用程序(在数字海洋Ubuntu 14.04)的电子邮件通过Mandrill和willio:mandrill包。部署之后,我可以使用Mandrill API在启动时从我的应用程序发送电子邮件。

Mandrill.messages.send({
   message: {
      "text": "Greetings from example.com!",
      "from_email": "demo@example.com",
      "from_name": "Keith - example.com",
      "subject": "App Started",
      "to": [
          { email: "ggg@gmail.com", name: "Keith" }
      ]
   }
}, function( error, response ) {
   if ( error ) {
      console.log( error );
}  else {
      console.log( response );
   }
});

此电子邮件发送,因此我知道我已设置MAIL_URL,并且可以从应用程序访问我的mandrill帐户。但是,当我尝试获取帐户绑定的电子邮件(例如验证电子邮件或重置密码)时,它不会发送。我相信这是因为我无法/不知道如何设置"来自"电子邮件领域,就像我上面的代码一样。但是我想这也可能是因为其他东西所以这里的代码改变了verifyEmail电子邮件的样子。

Accounts.emailTemplates.verifyEmail.subject = function(user) {
    return 'Activate your new account';
}
Accounts.emailTemplates.verifyEmail.html = function (user, url) {
    var result;
    try {
        result = Mandrill.templates.render({
            template_name: 'verify-email',
            template_content: [
                {
                    name: 'CONFIRMURL',
                    content: url
                },
                {
                    name: 'FNAME',
                    content: user.username
                }
            ],
            merge_vars: [
                {
                    name: 'CONFIRMURL',
                    content: url
                },
                {
                    name: 'FNAME',
                    content: user.username
                }
            ]
        });
    } catch (error) {
        console.error('Error while rendering Mandrill template', error);
    }
    return result.data.html;
}

如何通过mandrill设置from字段或以其他方式修复验证邮件? 顺便说一下,我正在使用本指南寻求帮助,但仍未能解决问题。 https://themeteorchef.com/snippets/sending-email-with-mandrill/

1 个答案:

答案 0 :(得分:1)

这是我在我的应用中设置电子邮件的方式:

  Accounts.emailTemplates.siteName = Meteor.settings.public.siteName;
  Accounts.emailTemplates.from = Meteor.settings.public.emailFrom;
相关问题