无法在heroku上从parse-server发送电子邮件

Han*_*ier 6 heroku parse-platform parse-server

我正在Heroku Parse-Server上运行我迁移的应用程序.当我尝试使用'requestPasswordResetInBackground'从我的应用程序发送密码重置电子邮件时,我收到以下错误:

"密码重置功能需要appName,publicServerURL和emailAdapter."

它曾经在Parse.com上正常工作.

我已经阅读了有关实现这个缺失功能​​的举措.有人知道这样的实现是否已经可用或将很快,如果是这样,如何配置它?

谢谢!

fla*_*me3 3

  1. 您需要访问 mailgun.com 并注册一个帐户。然后在mailgun中创建一个新域。您将获得该域的 api 密钥。
  2. 然后,您需要阅读解析迁移的自述文件 https://github.com/ParsePlatform/parse-server/blob/master/README.md。有邮件枪的例子。它位于 Parse Server 中,因此您无需安装任何额外的模板或在 index.js 中需要某些内容。

  3. 在您的index.js 中添加以下代码。应该是在你的服务器初始化之后

    var server = ParseServer({
    //... your other configurations
    // here the configuration for email begins
    verifyUserEmails: true,  //depends on your needs, you can set it to false 
    emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
    preventLoginWithUnverifiedEmail: false, // defaults to false
    
    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)

在 Parse 服务器中更改更新的 index.js 后,您将能够从 mailgun 获取电子邮件。可能需要几分钟才能收到电子邮件。

然后你还需要在你自己的服务器上实现电子邮件重置html页面。我还没有找到好的教程。

如果您直接通过 Heroku 安装 Parse 服务器,您将拥有server.js而不是index.js,您可以在以下目录中找到它: /opt/bitnami/apps/parse/htdocs/ 并在此文件中进行所有更改,然后重新启动服务器