parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

add emailAdapter to ENV variables

Open Cliffordwh opened this issue 10 years ago • 34 comments

Is it possible to add the emailAdapter to the env variables? like we have done with push and files etc.

I'm not making use of the index.jsfile from the sample. Firing off a json config. So not sure where to add the mailgun adapter with its vars.

Thanks

Cliffordwh avatar Mar 30 '16 13:03 Cliffordwh

If you are using a JSON config env var, you can configure your email adapter like this:

  "emailAdapter": {
    "module": "parse-server-simple-mailgun-adapter",
    "options": {
      "fromAddress": "[email protected]",
      "domain": "example.com",
      "apiKey": "key-mykey"
    }
  }

drew-gross avatar Mar 30 '16 16:03 drew-gross

@drew-gross Set it as described but the logs for parse-server show the following when i try reset:

Uncaught internal server error. Trying to send a reset password but no adapter is set undefined

My json looks as follows:

{
  "apps" : [{
    "name"        : "parse-server",
    "script"      : "/usr/bin/parse-server",
    "watch"       : true,
    "merge_logs"  : true,
    "cwd"         : "/home/parse",
    "env": {
      "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
      "PARSE_SERVER_DATABASE_URI": "xxxx",
      "PARSE_SERVER_APPLICATION_ID": "xxx",
      "PARSE_SERVER_MASTER_KEY": "xx",
      "PARSE_SERVER_FILE_KEY": "xxxx",
      "PARSE_SERVER_JAVASCRIPT_KEY": "xxxx",
      "PARSE_SERVER_REST_API_KEY": "xxxx",
      "PARSE_SERVER_MOUNT_PATH" : "",
      "PARSE_SERVER_FILES_ADAPTER" : "parse-server/lib/Adapters/Files/S3Adapter",
      "S3_ACCESS_KEY" : "xxx",
      "S3_SECRET_KEY"  : "xxxxxx",
      "S3_BUCKET" : "xxxxx",
      "S3_DIRECT_ACCESS" : "true",
      "PARSE_SERVER_FACEBOOK_APP_IDS" : "xxxxxxx",
      "PARSE_SERVER_PUSH" :  {"adapter" : "./Push/OneSignalPushAdapter",
                                             "oneSignalAppId": "xxxxxxx",
                                             "oneSignalApiKey": "xxxxxxxxx"
                             },
      "emailAdapter" : {
           "module": "parse-server-simple-mailgun-adapter",
                  "options": {
                  "fromAddress": "xxxxxx",
                  "domain": "xxxxxx",
                  "apiKey": "xxxxxxx"
    }
      }
    }
  }]
}

Cliffordwh avatar Mar 31 '16 12:03 Cliffordwh

did you add parse-server-simple-mailgun-adapter to your package?

flovilmart avatar Mar 31 '16 12:03 flovilmart

@flovilmart how would i do that? I did run npm i parse-server-simple-mailgun-adapter

This did however give warnings

npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.

Cliffordwh avatar Mar 31 '16 12:03 Cliffordwh

ok you don't have a base package... how did you setup parse-server?

flovilmart avatar Mar 31 '16 12:03 flovilmart

i used the global install npm - g !

Cliffordwh avatar Mar 31 '16 12:03 Cliffordwh

so install with npm i -g parse-server-simple-mailgun-adapter

flovilmart avatar Mar 31 '16 12:03 flovilmart

i did, thanks. But still get the Uncaught internal server error. Trying to send a reset password but no adapter is set undefined

Cliffordwh avatar Mar 31 '16 12:03 Cliffordwh

@flovilmart is there a reason that emailAdapter is not listed in the cli-definitions file?

Cliffordwh avatar Mar 31 '16 13:03 Cliffordwh

maybe because it's missing :)

flovilmart avatar Mar 31 '16 13:03 flovilmart

lol, could that be the reason why its not available?

Cliffordwh avatar Mar 31 '16 13:03 Cliffordwh

I'll post a fix or you could do it :)

flovilmart avatar Mar 31 '16 13:03 flovilmart

Thanks

Cliffordwh avatar Mar 31 '16 13:03 Cliffordwh

deff solved my problem, all working now! . Now i can just make use of PARSE_SERVER_EMAIL_ADAPTER. or whatever you name it.

"emailAdapter": {
    env: "PARSE_SERVER_EMAIL_ADAPTER",
    action: function action(opt) {
      return JSON.parse(opt);
    }
  },

Cliffordwh avatar Mar 31 '16 13:03 Cliffordwh

Thanks again. will wait on the update!

Cliffordwh avatar Mar 31 '16 13:03 Cliffordwh

Does it work with the emailAdapter option in --emailAdapter or config?

flovilmart avatar Mar 31 '16 15:03 flovilmart

works with option. As above.

Cliffordwh avatar Mar 31 '16 15:03 Cliffordwh

I'm having exact same problem. I migrated an app to digitalocean following this tuturial https://www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04

Can you please tell me where to add emailAdapter.

junal avatar Apr 03 '16 02:04 junal

@junal The changes to the CLI-Definitions will be available in the next update. This will allow you then to set your eco file with the settings above. In-fact just check, cause i think it was already added.

 "emailAdapter": {
    env: "PARSE_SERVER_EMAIL_ADAPTER",
    help: "Adapter module for the email sending",
    action: function action(opt) {
      if (typeof opt == 'object')  {
        return opt;
      }
      try {
        return JSON.parse(opt);
      } catch(e) {}
      return opt;
    }
  },

Cliffordwh avatar Apr 03 '16 08:04 Cliffordwh

@Cliffordwh Thanks! I have updated version of parse-server. So I added the ENV variable like this at /home/parse/ecosystem.json file

{
  "apps": [
    {
      "name": "parse-wrapper",
      "script": "/usr/bin/parse-server",
      "watch": true,
      "merge_logs": true,
      "cwd": "/home/parse",
      "env": {
        "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
        "PARSE_SERVER_DATABASE_URI": "XXX",
        "PARSE_SERVER_APPLICATION_ID": "XXX",
        "PARSE_SERVER_MASTER_KEY": "XXX",
        "PARSE_SERVER_EMAIL_ADAPTER": "parse-server-simple-mailgun-adapter"
      }
    }
  ]
}

But i still get the error message..."error: Uncaught internal server error. Trying to send a reset password but no adapter is set undefined".

What am I missing?

junal avatar Apr 03 '16 16:04 junal