Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Malformed email link generated with {{link}} #30

Closed
LaChrome opened this issue May 25, 2017 · 6 comments
Closed

Malformed email link generated with {{link}} #30

LaChrome opened this issue May 25, 2017 · 6 comments

Comments

@LaChrome
Copy link

LaChrome commented May 25, 2017

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://s1.serverlink.com/parse/apps/aZasdkfjRUEKC7qr2Aef6MdIvIXbofWGJRJbicZ/verify_email?token=bND8qgznUgAcusKQlzWKJkmeJ&username=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) noreply@serverlink.com',
// 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

@sebsylvester
Copy link
Owner

Hi Chris,
Thanks for the heads up. You're the first dev to report this issue, but I can imagine that more parse developers will experience the same problem as soon as they upgrade their app. I will have to dive into the parse server codebase to find out what's going on. When I do, I'll let you know.

@LaChrome
Copy link
Author

I think I found the issue. On the dev server, I had the public server URL set to https:// , where only http was configured on the dev server, and there was no fallback to http, which meant that the public html link wasn't reachable online.

Changing the public server link to http fixed the issue.

So ... I assume this same behaviour would occur with any incorrect public server address. Not sure if a malformed link being created as a result is the most helpful haha, but that may be a separate issue...

Also, not sure at this point if it was a result of something in parse-server or the mailgun adapter.

Moral of the story: Get your public link correct ..... https or otherwise. :)

@sebsylvester
Copy link
Owner

sebsylvester commented May 25, 2017

After doing some testing, I have learned that the malformed link is caused by the Mustache template rendering engine and not the parse server. It's actually not a "malformed" link, but just an html encoded version, and it still works in the browser. However, for plain-text emails (i.e. html templates are not configured) this is a problem, and the link will not work because the email client does not recognize it as such. This is something I will need to fix.

@LaChrome
Copy link
Author

Nicely done. Cheers

@sebsylvester
Copy link
Owner

I've updated the email templates. {{link}} => {{{link}}}
The extra curly brace prevents the html escaping. Problem solved :)

@LaChrome
Copy link
Author

LaChrome commented May 30, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants