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

upgrade mailgun driver & deprecate #37

Merged
merged 4 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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