Giter Site home page Giter Site logo

parse-community / parse-server-simple-mailgun-adapter Goto Github PK

View Code? Open in Web Editor NEW
84.0 18.0 103.0 61 KB

Used to send Parse Server password reset and email verification emails though Mailgun

License: Other

JavaScript 100.00%
parse-server mailgun mailgun-adapter email-verification reset-password

parse-server-simple-mailgun-adapter's Introduction

DEPRECATED

This mail adapter has been deprecated. Instead, use one of the community provided mail adapters.


Parse Server Simple Mailgun Adapter

npm version

Used to send Parse Server password reset and email verification emails though Mailgun

Installation

npm install --save @parse/simple-mailgun-adapter


As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.

parse-server-simple-mailgun-adapter's People

Contributors

acinader avatar awgeorge avatar chrisgrant avatar davimacedo avatar dependabot[bot] avatar drew-gross avatar flovilmart avatar lacker avatar mtrezza avatar theill avatar tomwfox 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parse-server-simple-mailgun-adapter's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Customize Verification and Reset Password Emails

Hey,

I'm using the parse-server-simple-mailgun-adapter for my email verification. I was wondering how to customize the emails being sent without having to change any of the parse-server code.

As far as I understand the UserController is responsible for the emails being sent for verification and password reset.

In the MailAdapter it is mentioned, that one could implement the sendVerificationEmail and sendPasswordResetEmail functions, which would also be considered changing parse-server code in my opinion (neglecting the fact, that I tried implementing these functions and failed. Miserably).

The parse-server-mailgun package works, but is there another way to do it only with parse-server, without having to rely on external packages?

Specific instructions on how to add mailgun adapter...

I am looking for more detailed instructions on and how to properly configure, and to get mailgun to work. I have about zero experience with Node, except from installing parse-server. It appears the tutorials assume a familiarity with node.js, its dependencies and abilities. Throughout the parse-server environment, the term "configuration file" (or something similar), is used without stating exactly which file is being referenced. (for those of us who don't know)

So far, this is what I have...
-mailgun acct
-parse-server-example successfully installed on aws (deployed from EB CLI, but never ran locally)
-parse-dashboard installed locally and working (can't seem to get this deployed on EB)
-node modules installed locally (including mailgun adapter)

parse-server & parse-dashboard work as listed above. As soon as I add the code listed here for mailgun, it breaks. I add it to the index.js that is running my parse-server. (is this the proper location?) I also have to comment out "...other options," or it creates its own error.

I have removed the log files from earlier, it turns out that section is the same whether it works or not. Both show basically identical errors, except adding mailgun code breaks install...

verification email does not work (password reset does)

Today I setup mailgun to enable password reset and verification emails on my parse-server.

After hour of troubleshooting why verification email is not working, I tried password reset and discovered that password reset was working fine.

I have tried to send a verification email on new users and old users without luck. mail-gun adapter setup should be fine as it sent the password reset emails. At the moment I cannot find a solution on the verification email. My index.js is attached (had to rename to .txt as it would not let me upload a .js). The server is running on bluemix. The following environmental variables are set (i do not list everything as it includes keys and since reset password is working they have to be set correctly):
EMAIL_VERIFY_TOKEN_VALIDITY_DURATION = 7200
VERIFY_USER_EMAIL = true

index.js.txtparse

Support new api key?

I have two mailgun accounts, one created from a long time ago, with the api key like "key-121314214" and other created today with the key like "21313414124-321312-32131"

The first works ok, the second no, any idea?

Tutorial

Hey,

I tried integrating this using npm install parse-server-simple-mailgun-adapter and couldn't get it to work. Maybe my domain settings are not configured properly on mailgun as the DNS records is showing a little error next to them on mailgun. How do I configure those for a server sitting at heroku.

My parse app is sitting on heroku. It's here: https://bookupapp.herokuapp.com

Can someone please write a good detailed tutorial on how to integrate this??

Regards.

Parse: Email verification issue

I made my Parse server through AWS EC2 with bitnami. I connected to my server's instance in the AWS console and added the this code in my server.js file:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
databaseURI: ".../bitnami_parse",
cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
appId: "...",
masterKey: "...",
fileKey: "...",
serverURL: 'https://ec2...compute.amazonaws.com:80/parse',
//CODE I ADDED FOR MAILGUN:
verifyUserEmails: true,
emailVerifyTokenValidityDuration: 2 * 60 * 60,
preventLoginWithUnverifiedEmail: false,
publicServerURL: 'https://ec2....compute.amazonaws.com:80/parse',
appName: 'Name',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'Name < [email protected] >',
// Your domain from mailgun.com
domain: 'email.com',
// Your API key from mailgun.com
apiKey: 'key-...',
}
}
});

After adding this I did the command sudo forever restartall. But when I sign my user up by email, I still do not get an email verification, however, in my parse dashboard the "emailVerified" column is set to "False". Then after a couple of hours, app stops working and gives me the error message: "can not make a secure connection to the server". If I take out the code I added in my server.js file, the app runs again and whenever I add a new user I do not get a verification email and the "emailVerified" column says "(undefined)"

How do I fix this? I've spent months searching and no one has been able to help me figure out this simple problem yet.

Mailgun send multiple emails instead of 1

Hello!
I have a problem I've asked in Stackoverflow, ServerFault and Parse Server several weeks ago with no answer, so this is my last chance to find the solution. I'll try to follow the steps to describe this "bug".

Issue Description

I migrated from Parse to Parse Server hosted in Digital Ocean (details below) and everything seemed to be working ok until I realized there was a problem sending emails (from the app through Cloud code and from Parse Server for email verification after the registration): the emails are sent multiple times, usually twice but sometimes 3, 4 even 5 or 6 times.
Of course I'm using parse-server-simple-mailgun-adapter.

Steps to reproduce

I'm not sure what are the steps, but this is my code and configuration:

Parse Server configuration > myparseuser/cloud/main.js

var api_key = 'key-myMailgunkey';
var domain = 'mg.mydomain.com';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
 Parse.Cloud.define("functiontosendemail", function(request, response) {
                   var name = request.params.username;
                   var email = request.params.email;
                   var body = request.params.body;
            var data = {
              from: email,
              to: '[email protected]',
              subject: "Contact Form",
              text: body
               };
        mailgun.messages().send(data, function (error, body) {
              console.log(body);
        });
});

Parse Server configuration > myparseuser/index.js

...
var api = new ParseServer({  
  ...,
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      fromAddress: '[email protected]',
      domain: 'mg.mydomain.com',
      apiKey: 'key-myMailgunkey'
    }
  }
});
...

Mailgun configuration:

Domain: mg.mydomain.com
State: Active
IPAddress: someipaddress
SMTP Hostname: smtp.mailgun.org
Default SMTP Login: [email protected]
Default password: defaultpassword #Note: I don't remember to use this password anywhere.
API Base URL: https://api.mailgun.net/v3/mg.mydomain.com
API Key: key-myMailgunkey
Inbound smap filter: Disabled
Wildcard domain: Off
DKIM selector: pic
Tracking hostname: email
Click tracking: Off
Open tracking: Off
Unsubscribes: Off
TLS Connection: Opportunistic
Certificate verification: Required
TXT record mg.mydomain.com (ok)
TXT record pic._domainkey.mg.mydomain.com (ok)
CNAME record email.mg.mydomain.com (checked)
MX records mxa.mailgun.org (checked)
MX records mxb.mailgun.org (checked)

Expected Results

I expected that each verification email was sent only once, and each contact email (via CloudCode) was sent only once.

Actual Outcome

Each email is sent usually twice but sometimes 3, 4, 5 or 6 times.

Environment Setup

  • Server

    • parse-server version 2.3.1
    • Operating System: Ubuntu 16.041
    • Hardware: 512MB RAM, 2GB Disk
    • Localhost or remote server? Digital Ocean
  • Database

    • MongoDB version: 3.0.14
    • Storage engine: Linux
    • Hardware: 512MB RAM, 2GB Disk
    • Localhost or remote server? Digital Ocean

Logs/Trace

If I send and email from the app calling "functiontosendemail" in rare occasions the email is sent and received only once. Usually the email is sent and received between 3 and 8 times In these cases, after more or less 1 minute my app receives from Parse Server this error:

com.parse.ParseRequest$ParseRequestException: i/o failure

Mailgun Log shows this two actions between 3 and 8 times:

Accepted: [email protected][email protected] 'Contact Form'
Delivered: [email protected][email protected] 'Contact Form'

What To Put as Mailgun Public Server URL

I have implemented parse-server-simple-mailgun-adapter with my Parse server to send email verifications and reset password emails. Everything is working perfectly fine, but I am concerned about the publicServerURL part because as of now I used my serverURL for this. So now when an email verification or a reset password email is sent, the link in the email body shows my serverURL, which is something I do not want.

So what can I put under publicServerURL?? Should I put the URL the projects website or is there another alternative? I have not found any information on this.

Emails not getting delivered

Running a parse-server-example project locally, have my index.js configured as so:

var api = new ParseServer({
  verifyUserEmails: true,
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'XXX',
  masterKey: process.env.MASTER_KEY || 'XXX', //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
  },
  publicServerURL: 'https://XXX.ngrok.io',
  appName: 'Apex',
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      // The address that your emails come from
      fromAddress: '[email protected]',
      // Your domain from mailgun.com
      domain: 'sandboxXXX.mailgun.org',
      // Your API key from mailgun.com
      apiKey: 'key-XXX',
    }
  },
});

when the reset request is sent, ngrok shows the request returning '200 OK' but no email is received. Mailgun shows no email being sent. no error message is shown, is there anything I can do to enhance logging or any additional config I need to do? Thanks

Server.js / AWS

After updating server.js for AWS somehow parse stop running below is the status.

emailAdapter: {
module: 'parse-server-mailgun',
options: {
// The address that your emails come from
fromAddress: 'xxx',
// Your domain from mailgun.com
domain: 'xxx',
// Your API key from mailgun.com
apiKey: 'key-xxx',
// The template section
}
}

----Status---

$ sudo /opt/bitnami/ctlscript.sh status
apache already running
parse not running
mongodb already running

How to install?

How do i install this? Is it standalone? If not how to intergate with the parse server? Im hosting on heroku.

i used this on the index.js

`// Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}

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!
fileKey: process.env.FILE_KEY || 'nofilekey',
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
verifyUserEmails: process.env.PARSE_SERVER_VERIFY_USER_EMAILS || false,
publicServerURL: process.env.PARSE_PUBLIC_SERVER_URL || 'http://localhost:1337/parse',
appName: process.env.PARSE_SERVER_APP_NAME || 'myAppName',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: process.env.DEFAULT_FROM_ADDRESS,
domain: process.env.MAILGUN_DOMAIN,
apiKey: process.env.MAILGUN_API_KEY,
}
},
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

`

ver resend verification email

Today I setup mailgun to enable password reset and verification emails on my parse-server.

After hour of troubleshooting why verification email is not working, I tried password reset and discovered that password reset was working fine.

I have tried to send a verification email on new users and old users without luck. mail-gun adapter setup should be fine as it sent the password reset emails. At the moment I cannot find a solution on the verification email. My index.js is attached (had to rename to .txt as it would not let me upload a .js). The server is running on bluemix. The following environmental variables are set (i do not list everything as it includes keys and since reset password is working they have to be set correctly):
EMAIL_VERIFY_TOKEN_VALIDITY_DURATION = 7200
VERIFY_USER_EMAIL = true

index.js.txtparse

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.