本文介绍了解析服务器简单Mailgun适配器'verifyUserEmails'问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是,而我的Parse Server在Heroku上完美运行。我是node.js和Express的新手,但我通过以下方式将适配器安装在分析服务器的根目录:

I am using the Parse Server Simple Mailgun Adapter, and my Parse Server is working perfectly on Heroku. I am new to node.js and Express, but I installed the adapter on the root of the Parse Server via:

npm i parse-server-simple-mailgun-adapter

这创建了一个node_modules文件夹,并基本克隆了Github存储库Mailgun适配器。我的index.js Parse Server配置如下所示:

This created a node_modules folder and essentially cloned the Github repository for the Mailgun Adapter. My index.js Parse Server configuration looks like:

var api = new ParseServer({
  verifyUserEmails: true,
  databaseURI: databaseUri || 'mongodb://DATABASE',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'APPID',
  masterKey: process.env.MASTER_KEY || 'MASTERKEY', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'https://SERVER/parse',  // Don't forget to change to https if needed
  publicServerURL: 'https://SERVER/parse',
  fileKey: process.env.FILE_KEY || 'FILEKEY',
  push: {
    ios: [
      {
        pfx: 'FILE.p12', // Dev PFX or P12
        bundleId: 'BUNDLE',
        production: false // Dev
      },
      {
        pfx: 'FILE.p12', // Prod PFX or P12
        bundleId: 'BUNDLE',  
        production: true // Prod
      }
    ]
  },
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      fromAddress: 'EMAIL@DOMAIN',
      domain: 'DOMAIN',
      apiKey: 'KEY',
    }
  },
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  }
});

在评论 verifyUserEmails 键。有了它,服务器将无法工作。 Mailgun适配器不管用。任何帮助将不胜感激。

The server works perfectly when commenting out the verifyUserEmails key. With it, the server will not work. The Mailgun adapter does not work regardless. Any help would be greatly appreciated. Thanks!

推荐答案

您是否设置了电子邮件适配器?

Did you set up the email adapter?

看看:

电子邮件验证和密码重置

Email verification and password reset

通过电子邮件地址验证用户电子邮件地址并启用密码重置。作为parse-server包的一部分,我们提供了一个通过Mailgun发送电子邮件的适配器。要使用它,请注册Mailgun,并将其添加到初始化代码中:

Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the parse-server package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:

var server = ParseServer({
  ...otherOptions,
  // Enable email verification
  verifyUserEmails: true,
  // The public URL of your app.
  // This will appear in the link that is used to verify email addresses and reset passwords.
  // Set the mount path as it is in serverURL
  publicServerURL: 'https://example.com/parse',
  // Your apps name. This will appear in the subject and body of the emails that are sent.
  appName: 'Parse App',
  // The email adapter
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      // The address that your emails come from
      fromAddress: '[email protected]',
      // Your domain from mailgun.com
      domain: 'example.com',
      // Your API key from mailgun.com
      apiKey: 'key-mykey',
    }
  }
});

您也可以使用社区贡献的其他电子邮件适配器,例如parse-server-sendgrid-adapter或parse-server-mandrill-adapter。

You can also use other email adapters contributed by the community such as parse-server-sendgrid-adapter or parse-server-mandrill-adapter.

OR

使用mailgun-js $创建您自己的云代码b $ b

Create your own in cloud code using mailgun-jshttps://www.npmjs.com/package/mailgun-js

var api_key = '[SECRET_API_KEY]';
var domain = '[DOMAIN_HERE]';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

Parse.Cloud.define('testemail', function(req, res) {
  var data = {
    from: 'Excited User <[email protected]>',
    to: '[email protected]',
    subject: 'Hello',
    text: 'Testing some Mailgun awesomness!'
  };

  mailgun.messages().send(data, function (error, body) {
    console.log(body);
  });

  res.success('Email Sent!');
});

这篇关于解析服务器简单Mailgun适配器'verifyUserEmails'问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 18:09