I am building an Android application using Parse Server Example on Heroku as backend. I need Mailgun to send password reset emails from ParseUI class ParseLoginHelpFragment. I haven't found an answer on how to make Mailgun work with Heroku/Parse Server. Here is my config on Heroku:
Also tried MAILGUN_SMTP_PORT 589 with the same result. Appreciate if anyone can point out the error in my setup.
EDIT: I understand that I need to enter the Mailgun API key and some additional setup. I have tried doing that in the index.js file:
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
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',
}
}
});
However, the app crashes on Heroku, there is still something missing...
Finally got this working:
1) Make sure that your domain is verified on Mailgun by using the steps they provide.
2) Check the zone settings for your domain with your hosting provider. The exact instruction may vary depending on the provider, I use Bluehost, and these settings are in Domains>>Zone settings
3) Create a mail address at your hosting provider and enter the email and password into Mailgun settings for the domain.
4) Replace code for var api
in index.js file:
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 || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
},
appName: 'Your App Name',
publicServerURL: 'https://yourappaddress.com/parse',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: '[email protected]',
// Your domain from mailgun.com
domain: 'email.yourappaddress.com',
// Your API key from mailgun.com
apiKey: 'key-private-key-from-mailgun',
}
}
});
If you don't use Heroku, you don't need to use process.env.*
Hope that helps