Cannot send email from parse-server on heroku

前端 未结 1 631
梦谈多话
梦谈多话 2021-02-09 19:22

i am running my migrated app on Heroku Parse-Server. When i try to send a password reset email from my app using \'requestPasswordResetInBackground\' i get the following error:

相关标签:
1条回答
  • 2021-02-09 19:49
    1. You need to go to mailgun.com and register an account. Then create a new domain in mailgun. You will get an api key for this domain.
    2. Then you need to read through the readme for parse migration https://github.com/ParsePlatform/parse-server/blob/master/README.md. There is example for mailgun. It is in the Parse Server so you don't need to install any extra template or require something at the index.js.

    3. Add the following code in your index.js. It should be after your server initialization

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

    After you change the updated index.js in your Parse server, you will be able to get email from mailgun. It could take some minutes to get the email.

    Then you also need to implement the email resetting html pages on your own server. I haven't found a good tutorial yet.

    If you installed the Parse server directly by Heroku, you will have server.js instead of index.js, you can find it in this directory: /opt/bitnami/apps/parse/htdocs/ and do all the changes in this file and restart the server

    0 讨论(0)
提交回复
热议问题