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

Commit

Permalink
Merge pull request #37 from mtrezza/upgrade-mailgun-driver
Browse files Browse the repository at this point in the history
upgrade mailgun driver & deprecate
  • Loading branch information
mtrezza authored Apr 7, 2021
2 parents d1c8437 + 766525d commit 92f14e4
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 572 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## 2.0.0
## Breaking Changes
- Upgraded to new native `mailgun.js` driver that does support the same options as the deprecated driver, see [docs](https://github.com/mailgun/mailgun-js#readme) (Manuel Trezza) [#37](https://github.com/parse-community/parse-server-simple-mailgun-adapter/pull/37)
## Notable Changes
(none)
## Other Changes
(none)
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# parse-server-simple-mailgun-adapter
# DEPRECATED

This mail adapter has been deprecated. Instead, use one of the [community provided mail adapters](https://github.com/parse-community/parse-server#email-verification-and-password-reset).

---
# Parse Server Simple Mailgun Adapter

<a href="https://www.npmjs.com/package/@parse/simple-mailgun-adapter"><img alt="npm version" src="https://img.shields.io/npm/v/@parse/simple-mailgun-adapter.svg?style=flat"></a>

Used to send Parse Server password reset and email verification emails though Mailgun
Expand Down
24 changes: 9 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@

var Mailgun = require('mailgun-js');
const Mailgun = require('mailgun.js');

var SimpleMailgunAdapter = mailgunOptions => {
const SimpleMailgunAdapter = mailgunOptions => {
if (!mailgunOptions || !mailgunOptions.apiKey || !mailgunOptions.domain || !mailgunOptions.fromAddress) {
throw 'SimpleMailgunAdapter requires an API Key, domain, and fromAddress.';
}
var mailgun = Mailgun(mailgunOptions);

var sendMail = mail => {
var data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
const mailgunClient = Mailgun.client({
username: 'api',
key: mailgunOptions.apiKey
});

return new Promise((resolve, reject) => {
mailgun.messages().send(data, (err, body) => {
if (typeof err !== 'undefined') {
reject(err);
return;
}
resolve(body);
});
});
const sendMail = mail => {
const data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
return mailgunClient.messages.create(mailgunOptions.domain, data);
}

return Object.freeze({
Expand Down
Loading

0 comments on commit 92f14e4

Please sign in to comment.