-
Notifications
You must be signed in to change notification settings - Fork 24
Malformed email link generated with {{link}} #30
Comments
Hi Chris, |
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. :) |
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. |
Nicely done. Cheers |
I've updated the email templates. {{link}} => {{{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://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
The text was updated successfully, but these errors were encountered: