在Heroku上为Parse-server-example设置Mailgun

Dmi*_*hov 1 android heroku mailgun parseui parse-server

我正在使用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',
        }
      }
    });
Run Code Online (Sandbox Code Playgroud)

然而,该应用程序在Heroku上崩溃,仍然有一些缺失......

Dmi*_*hov 6

终于搞定了这个:

1)确保使用他们提供的步骤在Mailgun上验证您的域.

2)使用您的托管服务提供商检查您的域的区域设置.具体说明可能因提供商而异,我使用Bluehost,这些设置位于域名>>区域设置中

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',
    }
  }

});
Run Code Online (Sandbox Code Playgroud)

如果您不使用Heroku,则无需使用 process.env.*

希望有所帮助