1

我正在使用 Heroku 上的 Parse Server Example 作为后端构建一个 Android 应用程序。我需要 Mailgun 从 ParseUI 类 ParseLoginHelpFragment 发送密码重置电子邮件。我还没有找到关于如何使 Mailgun 与 Heroku/Parse Server 一起工作的答案。这是我在 Heroku 上的配置:

在此处输入图像描述

还尝试了 MAILGUN_SMTP_PORT 589,结果相同。感谢是否有人可以指出我的设置中的错误。

编辑:我知道我需要输入 Mailgun API 密钥和一些额外的设置。我曾尝试在 index.js 文件中这样做:

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: 'parse@example.com',
          // Your domain from mailgun.com
          domain: 'example.com',
          // Your API key from mailgun.com
          apiKey: 'key-mykey',
        }
      }
    });

然而,应用程序在 Heroku 上崩溃了,仍然缺少一些东西......

4

2 回答 2

7

终于得到了这个工作:

1) 确保使用 Mailgun 提供的步骤验证您的域。

2) 与您的托管服务提供商检查您的域的区域设置。确切的说明可能因提供商而异,我使用 Bluehost,这些设置在 Domains>>Zone settings

3) 在您的托管服务提供商处创建一个邮件地址,并将电子邮件和密码输入到域的 Mailgun 设置中。

4) 替换var apiindex.js 文件中的代码:

var api = new ParseServer({


databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  },
  appName: 'Your App Name',
  publicServerURL: 'https://yourappaddress.com/parse',
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      // The address that your emails come from 
      fromAddress: 'yourapp@yourappaddress.com',
      // Your domain from mailgun.com 
      domain: 'email.yourappaddress.com',
      // Your API key from mailgun.com 
      apiKey: 'key-private-key-from-mailgun',
    }
  }

});

如果你不使用 Heroku,你不需要使用process.env.*

希望有帮助

于 2016-06-10T07:17:22.967 回答
0

如果您还没有这样做,则需要使用 npm 安装解析服务器简单的 mailgun 适配器。只需转到 parse-server-example 目录的根目录:npm install parse-server-simple-mailgun-adapter。

于 2016-08-25T22:01:34.030 回答