Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot send email from parse-server on heroku

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:

"An appName, publicServerURL, and emailAdapter are required for password reset functionality.".

It used to work fine on Parse.com.

I’ve read about initiatives for implementing this missing functionality. Does anybody know if such an implementation is already available or will be soon, and if so how to configure it?

Thanks!

like image 363
Hans Nulvier Avatar asked Jun 07 '16 21:06

Hans Nulvier


1 Answers

  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: '[email protected]',
      // 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

like image 70
flame3 Avatar answered Jan 03 '23 16:01

flame3