Skip to content

Commit 19e7f2c

Browse files
committed
updated demo script
1 parent 4946094 commit 19e7f2c

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

demo/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
'use strict';
2+
13
/**
24
* ==============================================================
35
* Demo script to send an email using the Mailgun API.
46
* ==============================================================
57
* Instructions:
68
*
7-
* 1. Create a file `mailgun.json` in the root directory with the
8-
* following keys to configure the test script:
9+
* 1. Create a file `mailgun.json` in the directory of this demo
10+
* script with the following keys to configure the demo script:
11+
*
912
* ```
1013
* {
1114
* key: "xxx", // The Mailgun API key.
@@ -16,13 +19,14 @@
1619
* }
1720
* ```
1821
*
19-
* 2. Run this script with `node ./demo` to send the email.
22+
* 2. Run this script with `node ./demo` to send an email. 🤞
2023
* ==============================================================
2124
*/
2225

2326
const ApiMailAdapter = require('../src/ApiMailAdapter');
2427
const ApiPayloadConverter = require('../src/ApiPayloadConverter');
25-
const mailgun = require('mailgun.js');
28+
const formData = require("form-data");
29+
const Mailgun = require('mailgun.js');
2630
const path = require('path');
2731

2832
const {
@@ -32,7 +36,11 @@ const {
3236
recipient
3337
} = require('./mailgun.json');
3438

35-
const mailgunClient = mailgun.client({ username: 'api', key: key });
39+
// Declare mail client
40+
const mailgun = new Mailgun(formData);
41+
const mailgunClient = mailgun.client({ username: "api", key });
42+
43+
// Configure mail client
3644
const filePath = (file) => path.resolve(__dirname, '../spec/templates/', file);
3745
const config = {
3846
sender: sender,

package-lock.json

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"codecov": "3.8.1",
4040
"eslint": "7.22.0",
4141
"eslint-plugin-flowtype": "5.4.0",
42+
"form-data": "4.0.0",
4243
"jasmine": "3.6.4",
4344
"madge": "4.0.2",
4445
"mailgun.js": "3.2.1",

0 commit comments

Comments
 (0)