Giter Site home page Giter Site logo

sebsylvester / parse-server-mailgun Goto Github PK

View Code? Open in Web Editor NEW
55.0 55.0 24.0 224 KB

Allows your Parse Server app to send template-based emails through Mailgun. Just add your template files (plain text and html) to the email adapter's configuration.

License: MIT License

JavaScript 92.29% HTML 7.71%
mailgun parse-server

parse-server-mailgun's People

Contributors

cmincarelli avatar dan-nyanko avatar fduch2k avatar sebsylvester avatar w0lfw00d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parse-server-mailgun's Issues

module parse-server-mailgun not found

I am running parse-server v2.3.1 and receives the below error.

Error: Cannot find module 'parse-server-mailgun'
2017-01-09T13:49:01.193976+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:470:15)
2017-01-09T13:49:01.193983+00:00 app[web.1]:     at Function.Module._load (module.js:418:25)
2017-01-09T13:49:01.193984+00:00 app[web.1]:     at Module.require (module.js:498:17)
2017-01-09T13:49:01.193984+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-01-09T13:49:01.193991+00:00 app[web.1]:     at loadAdapter (/app/node_modules/parse-server/lib/Adapters/AdapterLoader.js:27:15)
2017-01-09T13:49:01.193992+00:00 app[web.1]:     at loadAdapter (/app/node_modules/parse-server/lib/Adapters/AdapterLoader.js:34:12)
2017-01-09T13:49:01.193993+00:00 app[web.1]:     at new ParseServer (/app/node_modules/parse-server/lib/ParseServer.js:279:65)
2017-01-09T13:49:01.194005+00:00 app[web.1]:     at new _ParseServer (/app/node_modules/parse-server/lib/index.js:46:16)
2017-01-09T13:49:01.194006+00:00 app[web.1]:     at Object.<anonymous> (/app/index.js:15:11)
2017-01-09T13:49:01.194006+00:00 app[web.1]:     at Module._compile (module.js:571:32)


The adapter configuration looks like this

emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
            // The address that your emails come from
      fromAddress:xxxxx,
      // Your domain from mailgun.com
      domain: xxxxx,
      // Your API key from mailgun.com
      apiKey: ******,
      templates: {
        transactionEmail: {
          subject: 'Urgent notification!',
          pathPlainText: resolve(__dirname, 'path/to/templates/custom_alert.txt'),
          pathHtml: resolve(__dirname, 'path/to/templates/custom_alert.html'),
        }
      }
    }
  }

I have checked "parse-server-mailgun" package is available in node_modules. But the error persists.

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

Hi,
I have the following setup

var api = new ParseServer({
databaseURI: process.env.MONGODB_URI,
cloud: __dirname + '/cloud/main.js',
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY,
serverURL: process.env.SERVER_URL ,
emailAdapter: {
module: 'parse-server-mailgun',
options: {
appName: 'MyAppName',
fromAddress: 'MyApName [email protected]',
// Your domain from mailgun.com
domain: 'myappname.com',
// Your API key from mailgun.com
apiKey: 'key-##############',
// The template section
templates: {
passwordResetEmail: {
subject: 'Reset your password',
pathPlainText: resolve(__dirname, 'email/PasswordReset.txt'),
pathHtml: resolve(__dirname, 'email/PasswordReset.html'),
callback: (user) => { return { firstName: user.get('username') }}
}
}
}
}
});

When attempting to reset password I get following error from parse:
An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.

But I think I have set all these things. Thanks

Quick question...

I have everything set up and done the following:

  1. Set up parse-server-mailgun
  2. Iinstalled mailgun.js
  3. Test and appears to be working
  4. Set up a Mailgun account and entered the credentials. I am using the same information I used with a curl command to test Mailgun
  5. I tested parse-sevrer-mailgun with the new mailgun information and everything appears to work

I am not receiving the mail and Mailgun has no log of the transaction even getting there.

What is the best way to debug this particular issue, no errors are reported in the server log and no errors get returned to my app so I am not sure where to start looking.

Lodash Templates Question

Hey!

I see that you're using lodash.templates but the templates look like handlebars with {{ }} curlies.

The reason I'm asking is because I'm trying to do a for loop and this didn't work:

{{#each items}}
{{/each}}

Thanks again!

Not able to send emails...

Hi,
Not able to send any reset password email. Here is my config which is within a (new ParseServer({)

emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
      // The address that your emails come from 
      fromAddress: '[email protected]',
      // Your domain from mailgun.com 
      domain: 'domain.here',
      // Your API key from mailgun.com 
      apiKey: 'key-****',
      // The template section 
      templates: {
        passwordResetEmail: {
          subject: 'Reset your password',
          pathPlainText: resolve(__dirname, '/home/admin/mail_templates/password_reset_email.txt'),
          pathHtml: resolve(__dirname, '/home/admin/mail_templates/password_reset_web.html') 
        }
      }
    }
  }

Can you guys help figure out what is wrong. Hidden key and domains on purpose.

Thanks

Mailgun Integration With Swift/Parse

In my project I want to implement two features:
1) Verify email confirmation during the sign up process.
2) Reset password via email. I am coding in Swift 3 with Parse and I have a MailGun account.

I have a Mailgun account and have linked it to my and have an active domain running. But after this I do not know how to integrate this with my Xcode project that is fully coded in Swift using a Parser Server. The Mailgun website has set up instructions for the email confirmation but none of the code is in Swift and I do not know how to transfer it to Swift. This is the same for all of the other links and articles I have found on the internet. The only thing I have tried and has worked is just sending a normal email using:

    let mailgun = Mailgun.client(withDomain: "****.com", apiKey: "key-*****")
    
    mailgun?.sendMessage(to: "user *email*", from: "*connected email*", subject: "Verify Email address", body: "Thank for signing up! Please press the link below to verify your email address.")

But to have a verfy email and change password function, I need more than the standard text and have a link that connects to the server to validate the email and change the password. The only thing I know is that Parse has the PFUser.requestPasswordResetForEmail feature but I do not know how to properly connect my Mailgun to the project so when I try to run it I recieve the error: "An appName, publicServerURL, and emailAdapter are required for password reset functionality."

Any help given on any part of this is greatly appreciated as this is a problem for thousands of other Swift coders. Thanks in advance!

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

I recently started getting this error when trying to reset the password in our app. I saw a previous issue about this however, I believe I have all the correct info and I am still getting this issue.

The Error Message:

error: Error handling request: ParseError {
code: 1,
'An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.' } code=1, message=An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.

My Index.js

emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
      appName: 'MyAppName',
      fromAddress: process.env.EMAIL_FROM_ADDRESS,
      domain: process.env.EMAIL_DOMAIN,
      apiKey: process.env.EMAIL_KEY,
      publicServerURL: process.env.SERVER_URL,
      templates: {
        passwordResetEmail: {
          subject: 'Reset Your Password',
          pathPlainText: '/email/PasswordReset.txt',
          pathHtml: '/email/PasswordReset.html'  
        }
      }
    }
  },

Any ideas what is causing this? Thanks!

Template paths

Hi again,
Now I want to add the paths for my custom templates that I made. The path is myparse-server/node_modules/parse-server-mailgun/Custom_Reset_Password_Folder/index.html.

How this path need to be written inside the index.js of my parse server?

Mailgun Adapter Not Sending Emails

Hello,
I set up my parse server for my iOS project using AWS with Bitnami. I added this to my server.js file:

verifyUserEmails: true,
publicServerURL: 'https://ec2../parse',
appName: 'name',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: ADDRESS',
domain: 'DOMAIN',
apiKey: 'KEY'

I thought that this was it, but when I sign up a user or try to reset a password, I do not get an email. The address, domain, and api key are all correct. I saw that somehow we are suppose to install the adapter through 'npm'. I have never installed something with npm before and do not know how to. I get access to my server through connecting to my instance by launching my SSH Client. How do I go from there to just add/install npm i parse-server-mailgun properly?

I have been working on this mailgun integration for months and I am in desperate need for help. So if anyone can give me any help I will be forever grateful!

TypeError: _.extend is not a function

Hey,

I've bee using this adapter for my emails with parse-server hosted on DigitalOcean. It's been working fine, until today with a fresh parse-server installation I started getting the following error:

parse-server-wrapper-0 TypeError: _.extend is not a function
parse-server-wrapper-0     at Object.<anonymous> (/usr/lib/node_modules/parse-server-mailgun/node_modules/cheerio/lib/cheerio.js:88:3)
parse-server-wrapper-0     at Module._compile (module.js:409:26)
parse-server-wrapper-0     at Object.Module._extensions..js (module.js:416:10)
parse-server-wrapper-0     at Module.load (module.js:343:32)
parse-server-wrapper-0     at Function.Module._load (module.js:300:12)
parse-server-wrapper-0     at Function._load (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
parse-server-wrapper-0     at Module.require (module.js:353:17)
parse-server-wrapper-0     at require (internal/module.js:12:17)
parse-server-wrapper-0     at Object.<anonymous> (/usr/lib/node_modules/parse-server-mailgun/node_modules/cheerio/index.js:5:28)
parse-server-wrapper-0     at Module._compile (module.js:409:26)

This is my ecosystem.json run with pm2.

{
  "apps" : [{
    "name"        : "parse-server-wrapper",
    "script"      : "/usr/bin/parse-server",
    "watch"       : false,
    "merge_logs"  : true,
    "cwd"         : "/home/parse",
    "env": {
      "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
      "PARSE_SERVER_DATABASE_URI": dburi",
      "PARSE_SERVER_APPLICATION_ID": "appid",
      "PARSE_SERVER_MASTER_KEY": "masterkey",
      "PARSE_PUBLIC_SERVER_URL": "serverurl",
      "PARSE_SERVER_MOUNT_PATH": "/parse",
      "VERBOSE": "1",
      "PARSE_SERVER_APP_NAME": "appname",
      "PARSE_SERVER_VERIFY_USER_EMAILS": true,
      "PARSE_SERVER_EMAIL_ADAPTER": {
          "module": "parse-server-mailgun",
          "options": {
            "fromAddress": "[email protected]",
            "domain": "example.com",
            "apiKey": "key-apikey",
            "templates": {
              "passwordResetEmail": {
                "subject": "Reset your password",
                "pathPlainText": "/usr/lib/node_modules/parse-server/public_html/password_reset_email.txt",
                "pathHtml": "/usr/lib/node_modules/parse-server/public_html/password_reset_email.html"
              },
              "verificationEmail": {
                "subject": "Confirm your account",
                "pathPlainText": "/usr/lib/node_modules/parse-server/public_html/verification_email.txt",
                "pathHtml": "/usr/lib/node_modules/parse-server/public_html/verification_email.html"
              }
            }
          }
      },
      "PARSE_SERVER_PREVENT_LOGIN_WITH_UNVERIFIED_EMAIL": true
    }
  }, {
    "name"        : "parse-dashboard-wrapper",
    "script"      : "/usr/bin/parse-dashboard",
    "watch"       : false,
    "merge_logs"  : true,
    "cwd"         : "/home/parse",
    "env": {
    ... dashboard stuff
    }
  }]
}

Environment:

parse-server 2.217
parse-server-mailgun 1.0.2

Issue Resolving template files

Parse email adapter settings

customEmailAlert: {
subject: 'Urgent notification!',
pathPlainText: path.join(__dirname, '/public/custom_alert.txt'),
pathHtml: path.join(__dirname, '/public/custom_alert.html'),
callback: (user) => { return { firstName: user.get('firstName') }}
}
When I test using the Cloud Function I get the following error

**{ Error: ENOENT: no such file or directory, open '/app/public/custom_alert.txt'
 errno: -2,
code: 'ENOENT',
 syscall: 'open',
path: '/app/public/custom_alert.txt' }**

But I am able to serve test.html by using the same path.

app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});

I am not sure what I am missing here.

SyntaxError?

Hi, am i doing something wrong or is there some syntax error?

Using latest parse-server and it works with 'parse-server-simple-mailgun-adapter'

emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
      fromAddress: '[email protected]',
      domain: 'mydomain.com',
      apiKey: 'key-xxxxxx',
      templates: {
        passwordResetEmail: {
          subject: 'Reset your password',
          pathPlainText: resolve(__dirname, 'test/email-templates/password_reset_email.txt'),
          pathHtml: resolve(__dirname, 'test/email-templates/password_reset_email.html'),
          callback: (user) => { return { firstName: user.get('firstName') }}
        },
        verificationEmail: {
          subject: 'Confirm your account',
          pathPlainText: resolve(__dirname, 'test/email-templates/verification_email.txt'),
          pathHtml: resolve(__dirname, 'test/email-templates/verification_email.html'),
          callback: (user) => { return { firstName: user.get('firstName') }}
        },
        customEmailAlert: {
          subject: 'Urgent notification!',
          pathPlainText: resolve(__dirname, 'test/email-templates/custom_alert.txt'),
          pathHtml: resolve(__dirname, 'test/email-templates/custom_alert.html'),
        }
      }
    }
  }

[email protected] start /opt/repo/ROOT
node index.js

DATABASE_URI not specified, falling back to localhost.
/opt/repo/ROOT/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:24
constructor(options = {}) {
^

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at loadAdapter (/opt/repo/ROOT/node_modules/parse-server/lib/Adapters/AdapterLoader.js:27:15)
at loadAdapter (/opt/repo/ROOT/node_modules/parse-server/lib/Adapters/AdapterLoader.js:34:12)
at new ParseServer (/opt/repo/ROOT/node_modules/parse-server/lib/ParseServer.js:279:65)

npm info lifecycle [email protected]~start: Failed to exec start script
npm ERR! Linux 2.6.32-042stab120.11
npm ERR! argv "/opt/jelastic-nodejs5.1/bin/node" "/bin/npm" "start" "-d"
npm ERR! node v5.1.1
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the parse-server-example package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get their info via:
npm ERR! npm owner ls parse-server-example
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /opt/repo/ROOT/npm-debug.log

Variable Subject line

Does the plugin support having a variable subject line?

If so, any suggestions on implementation?

Support eu-mails

Mailgun supports sending emails from the eu, but you need to use another host: api.eu.mailgun.net
Can you please provide a config-item "host" and pass it to the mailgun-js package?

Error with Setup

throw new Error("only one instance of babel-polyfill is allowed");

peerDependencies issue

I just wanted to upgrade to the latest parse-server version 2.2.25-beta.1 and got following error:

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies

mailgun.json doesn't work?

Hi, I installed the module in my parse server, I created the mailgun.json in the root folder, and I ran node ./src/mailgun-tester from the module's root folder and this is the error I got :

/root/myparse-server/node_modules/parse-server-mailgun/src/mailgun-tester/index.js:24
    User: class User {
          ^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:148:18)
    at node.js:405:3

My node version is v5.12.0

Mail tags & tracking options

As I found - adapter doesn't support setting 'o:tags' & 'o:tracking' (-opens)
Am I mistaken? If so - what's the way to do it?

No logs on mailgun

Hi,
I installed (and solved a quick issue with babel-polyfill vesion, parse-server module require 6.8.0).
I fix the path error I received first time I ran the app, but now when I e.g. signup with a new email, nothing appears in the console and no log on mailgun or on Nodejs.

How can I troubleshoot and log what is appening?
I'm using the last available version of Parse server ..22.

Thank you,
Michele

Is there any option for a callback?

Hey,

Love your module!

I was looking through the code and I didn't see anything about a success / error callback. Is there anything I can use after running

MailgunAdapter.send() to see if it's been sent successfully or if there were some error?

If not, would you be open to a PR that adds this feature?

Thanks again! You rock!

Email Confirmation and Password Reset Link

Hello,

I have successfully implement the mailgun adapter to my parse server and users receive working emails for email confirmation and password resets. Everything is working fine, but I want to change the link they receive in these emails. As of now the link to confirm their account of reset their password shows the link to my AWS instance URL (https://ec2-xxxxxxxxx.compute.amazonaws.com:80/parse/apps/xxxxxxxx). I do not want this and instead I want the part that shows my instance's URL to be replaced with my website's URL (www.example.com) where they can still confirm their email or reset their password.

This is a question that can help so many people so any help at all will be appreciated.

Returning Internal Server Error

I am using the code as defined in the templates section and get this:

 [TypeError: Cannot read property 'userController' of null] TypeError: Cannot read property 'userController' of null

Thoughts?

BCC field not working in extras

I'm attempting to add two BCC email addresses through environment variables in the format [email protected],[email protected] but it is not working. I checked the tests and it looks like this isn't covered. How can I see if this is working? Here's my code:

    return MailgunAdapter.send({
      templateName: 'receiptEmail',
      subject: 'Your order receipt',
      fromAddress: 'Sender <[email protected]>',
      recipient: billingAddress.email,
      variables: { 
        firstName: billingAddress.first_name,
        orderId: orderId
      },
      extra: {
        bcc: process.env.CUSTOMER_EMAIL_BCC
      }
    });

Thanks!

can't open attached files

Code

I tried to send a .pdf file using this config

var filePath = path.join(res.filename);
var data = fs.readFileSync(filePath);

MailgunAdapter.send({
    templateName: 'testTemplate',
    subject: 'Subject',
    fromAddress: 'From Address <[email protected]>',
    recipient: request.object.get("email"),
    variables: {
        variables: "variables"
    },
    extra: {
        attachments: [data]
    }
})

if i send the same things with the mailgun-js function it is working

var filePath = path.join(res.filename);
var data = fs.readFileSync(filePath);

var data = {
    fromAddress: 'From Address <[email protected]>',
    recipient: request.object.get("email"),
    subject: 'Hello',
    text: 'Testing some Mailgun awesomeness!',
    attachment: data
};

mailgun.messages().send(data, function(error, body) {
    console.log(body);
})

i've also tried to send it via the Attachment Object of mailgun-js

var filePath = path.join(res.filename);
var data = fs.readFileSync(filePath);
var filename = 'test.pdf';

var attch = new mailgun.Attachment({
    data,
    filename,
    contentType: 'application/pdf'
}); 

again it worked for the mailgun-js .send() function but not for the MailgunAdapter .send()

Mailgun Dashboard Logs

Every File which was sent by MailgunAdapter seemed to be empty. I've checked the logs in the mailgun dashboard and the filesize was just few bytes. For the mails sent via mailgun-js were the same values just the size and name were different:

mailgun-js
(if i sent it just with a Buffer object the filename is "file" but it works if i open it. If i use the mailgun-js Attachment Object the filename is valid like "test.pdf")

"message": {
    "headers": {
        "to": "*********",
        "message-id": "*******@mg.*****.com",
        "from": "***** <*****@*****.com>",
        "subject": "Hello"
    },
    "attachments": [{
        "size": 214977,
        "content-type": "application/octet-stream",
        "filename": "file"
    }],
    "size": 215544
}

MailgunAdapter
(If i use the Buffer Object to send out the file is always a .bin file. If i use the mailgun-js Attachment Object the pdf looks like a valid file but i can't open it.)

"message": {
    "headers": {
        "to": "*********",
        "message-id": "*******@mg.*****.com",
        "from": "***** <****@*****.com>",
        "subject": "Hello"
    },
    "attachments": [{
        "size": 125,
        "content-type": "application/octet-stream",
        "filename": "attachment-1.bin"
    }],
    "size": 53112
}

Do you guys have an idea whats wrong ๐Ÿค” ?

Thanks!

Link in text email is URL-encoded

The {{link}} value is URL-encoded, which is fine for the HTML email, but not so good for the plain-text one. Here's what I see in my text-only email:

To reset your password, visit this link:
http:&#x2F;&#x2F;localhost:1337&#x2F;parse&#x2F;apps&#x2F;TKR&#x2F;request_password_reset?token&#x3D;i65ngBIDzt5tQ02MzhnA4s8s6&amp;username&#x3D;steve%mydomain.com

Password Reset Error

Password Reset throws the following error: requestPasswordReset: The server responded with a status of 500 Internal Server Error.

Any idea why this is occurring?

Email subject templating

Hi,

Is it possible to use variables in the subject of the email? I need something dynamic for this part of the email too.

if not, maybe just adding a function like that would solve the problem:

(user) => {
    // returns the dynamic subject
    return `Hello ${user.username}`
}

And this could be added in the configuration like that:

passwordResetEmail: {
          subject: 'reset password',
          // optionnal
          subjectConstructor: (user) => {
                  return `Hello ${user.username}`
          },
          pathHtml: resolve(__dirname, 'templates/reset_password_email.html'),
          pathPlainText: '',
          callback: (user) => { return {
            firstName: user.get('firstName')
          }}
}

What do you think?

Error: MailgunAdapter templates are not properly configured.

.../samples/api-server/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:43
throw new Error(ERRORS.bad_template_config);
^

Error: MailgunAdapter templates are not properly configured.

I am trying to integrate Parse as a service in another express-server (feathers.js). All other mailgun adapters work except this one...server/parse boots fine.

Does it have to do with babel transpiler you think? I've tried with

require("babel-register"); no luck.

I'm fresh to js. would like to use this for templates.

Install fails on bcrypt 404.

Hey,

I'm trying to install using: npm install -g parse-server-mailgun but the install fails due to a 404 on the bcrypt package. Below is the returned stacktrace.

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v46-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v46 ABI) (falling back to source compile with node-gyp)

Malformed email link generated with {{link}}

Hi,
On my development platform, I've updated to:
Parse server 2.4.1 (Latest as of today) and
parse-server-mailgun 2.4.4 (Latest version as of today).

Upon registering a new Parse user (successful), an email confirmation is successfully sent, but the link is malformed in the email being sent.

This isn't happening in the production version (running Parse 2.3.1), where the configuration all looks the same.

This is how the {{link}} in the email comes through as:

https:&#x2F;&#x2F;s1.serverlink.com&#x2F;parse&#x2F;apps&#x2F;aZasdkfjRUEKC7qr2Aef6MdIvIXbofWGJRJbicZ&#x2F;verify_email?token&#x3D;bND8qgznUgAcusKQlzWKJkmeJ&amp;username&#x3D;Joe%20low

Here is the mailgun config from the index.js:

publicServerURL: 'https://s1.serverlink.com/parse', // Production
appName: 'CoolApp',
verifyUserEmails: true,
//new full mailgun adapter
emailAdapter: {
module: 'parse-server-mailgun',
options: {
// The address that your emails come from
fromAddress: 'Apptation (No Reply) [email protected]',
// Your domain from mailgun.com
domain: 'mg. serverlink.com',
// Your API key from mailgun.com
apiKey: process.env.MAILGUN_KEY, //mailgun key
// The template section
templates: {
passwordResetEmail: {
subject: 'Reset your password',
pathPlainText: resolve(__dirname, 'emailTemplates/resetPasswordEmail.txt'),
pathHtml: resolve(__dirname, 'emailTemplates/resetPasswordEmail.html'),
callback: (user) => { return { firstName: user.get('username') }}
// Now you can use {{firstName}} in your templates
},
verificationEmail: {
subject: 'Confirm your account',
pathPlainText: resolve(__dirname, 'emailTemplates/verifyEmail.txt'),
pathHtml: resolve(__dirname, 'emailTemplates/verifyEmail.html'),
callback: (user) => { return { firstName: user.get('username') }}
// Now you can use {{firstName}} in your templates
}
}
}
}

So ... verification email is sent fine, but the link doesn't come through properly.
The file "verifyEmail.txt" is pretty straight forward, and I've even simplified it to only contain {{link}} for testing, which gives me the same result.

Am I missing something obvious here? It's working in production Parse server v2.3.1 and the config looks the same, so I'm not sure what's going on.

Thanks

Chris

Error: 'to' parameter is missing

I'm trying to setup my mailgun detail with the parse-server-mailgun for Password reset

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 || 'myMasterKey', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
  publicServerURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
  appName: '*APPNAME*',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  },
  emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
      // The address that your emails come from
      fromAddress: '*ADDREss*',
      // Your domain from mailgun.com
      domain: '*DOMAIN*',
      // Your API key from mailgun.com
      apiKey: '*APIKEU*',
      templates: {
        passwordResetEmail: {
            subject: 'Reset your password',
            pathPlainText: path.join(__dirname, 'email-templates/password_reset_email.txt'),
            pathHtml: path.join(__dirname, 'email-templates/password_reset_email.html')
        }
      }
    }
  }
});

But I'm getting the error on the Mailgun Plugin as if the module wasn't sending the email address to mailgun
Error: 'to' parameter is missing

Error with Setup

throw new Error("only one instance of babel-polyfill is allowed");

Mailgun working but cant connect to app for password reset.

Hi,

I Have followed all the steps as mentioned by you, without any trouble I can test the mailgun adapter by using the below syntax and can also see the mail is working absolutely fine.
sytntax: node ./src/mailgun-tester

However, I am clueless what do i do in my android app to reset the password, I still keep getting the same issue. Thanking you in advance for your help

Question about parse-server-mailgun...

Hello,

I have set up a parse server and need to send mail. I installed https://github.com/parse-community/parse-server-simple-mailgun-adapter and https://github.com/mailgun/mailgun-js

BUT, I was wondering if your parse-server-mailgun can be used in place of those?

I am pretty new to parse but have a fairly good understanding. I just wanted to know if you could answer a few questions:

  1. If I use your code do I need mailgun-js and/or the parse adaptor?
  2. Will this work with the Parse password reset, or do I need to provide my own call to send a password reset email
  3. Do I just need to install your parse-server-mailgun and mustache? What mailgun items need to be installed?

Thank you os much for any help you can give me!!!

Best,
Tony

[ReferenceError: username is not defined] if used within cloudcode

Hello,
mailgun module for system emails works fine, but when I'm trying to use mailgun module inside a cloudcode function the following error appears:

[ReferenceError: username is not defined]

My simple main.js is:

const AppCache = require('parse-server/lib/cache').AppCache;
const MailgunAdapter = AppCache.get('myAppId')['userController']['adapter'];

//EMAIL TEST
Parse.Cloud.define("email", function(request, response){
        // Invoke the send method with an options object
        MailgunAdapter.send({
          templateName: 'verificationEmail',
          // Optional override of your configuration's subject
          subject: 'Important: action required',
          // Optional override of the adapter's fromAddress
          fromAddress: 'Alerts <[email protected]>',
          recipient: '[email protected]',
          variables: { alert: 'New posts' } // {{alert}} will be compiled to 'New posts'
        });
});

I use this curl script to test the function:

  curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -H "X-Parse-Session-Token: r:80b274d910103d65dc7f9704e2a68829" \
  http://dev.replave.io/parse/functions/email

Sever stdoutput:

verbose: REQUEST for [POST] /parse/functions/email: {} method=POST, url=/parse/functions/email, host=dev.replave.io, user-agent=curl/7.50.1, accept=*/*, x-parse-application-id=myAppId, content-type=application/json, x-parse-session-token=r:80b274d910103d65dc7f9704e2a68829,
[ReferenceError: username is not defined]

Env:
Ubuntu 16.04.1 LTS
npm 3.10.8
node v4.2.6
parse-server 2.2.22

Do you have any idea on how to fit it?
Thank you

email sending broken on latest parse-server 2.2.22

Issue Description

I'm running stable version of parse-server with parse-server-mailgun module to send customized welcome and password reset emails. Worked fine since beg of August.

Since yesterday when I updated to the latest 2.2.22 the password reset emails are not being sent and parse server logs the following exception:

Downgrading to 2.2.21 and 2.2.20 does not help.

The password reset emails work great in 2.2.19 which I reverted to get everything back to work.

#033[31merror#033[39m: Error generating response. ReferenceError: regeneratorRuntime is not defined
     at MailgunAdapter._sendMail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:134:23)
     at MailgunAdapter.sendPasswordResetEmail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:251:25)
     at /parse/node_modules/parse-server/lib/Controllers/UserController.js:194:26
     at process._tickDomainCallback (internal/process/next_tick.js:129:7) 
 #033[31merror#033[39m: Uncaught internal server error. ReferenceError: regeneratorRuntime is not defined
     at MailgunAdapter._sendMail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:134:23)
     at MailgunAdapter.sendPasswordResetEmail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:251:25)
     at /parse/node_modules/parse-server/lib/Controllers/UserController.js:194:26
     at process._tickDomainCallback (internal/process/next_tick.js:129:7) ReferenceError: regeneratorRuntime is not defined
     at MailgunAdapter._sendMail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:134:23)
     at MailgunAdapter.sendPasswordResetEmail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:251:25)
     at /parse/node_modules/parse-server/lib/Controllers/UserController.js:194:26
     at process._tickDomainCallback (internal/process/next_tick.js:129:7)
 ReferenceError: regeneratorRuntime is not defined
     at MailgunAdapter._sendMail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:134:23)
     at MailgunAdapter.sendPasswordResetEmail (/parse/node_modules/parse-server-mailgun/lib/MailgunAdapter.js:251:25)
     at /parse/node_modules/parse-server/lib/Controllers/UserController.js:194:26
     at process._tickDomainCallback (internal/process/next_tick.js:129:7)

Steps to reproduce

  emailAdapter: {
    module: 'parse-server-mailgun',
    options: {
      fromAddress: 'XXX <[email protected]>',
      domain: 'mg.yyy.zzz',
      apiKey: 'key-XXXXXXXXX',
      templates: {
        passwordResetEmail: {
          subject: 'Password Reset',
          pathPlainText: resolve(__dirname, 'templates/password_reset_email.txt'),
          pathHtml: resolve(__dirname, 'templates/password_reset_email.html'),
          //callback: (user) => { return { firstName: user.get('firstName') }}
          // Now you can use {{firstName}} in your templates 
        },
        verificationEmail: {
          subject: 'Welcome',
          pathPlainText: resolve(__dirname, 'templates/verification_email.txt'),
          pathHtml: resolve(__dirname, 'templates/verification_email.html'),
          //callback: (user) => { return { firstName: user.get('firstName') }}
          // Now you can use {{firstName}} in your templates 
        }
      }
    }
  },

Expected Results

Password reset email sent.

Actual Outcome

Password reset emails not sent, parse-server returning ERROR.

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.2.22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.