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.
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
2326const ApiMailAdapter = require ( '../src/ApiMailAdapter' ) ;
2427const ApiPayloadConverter = require ( '../src/ApiPayloadConverter' ) ;
25- const mailgun = require ( 'mailgun.js' ) ;
28+ const formData = require ( "form-data" ) ;
29+ const Mailgun = require ( 'mailgun.js' ) ;
2630const path = require ( 'path' ) ;
2731
2832const {
@@ -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
3644const filePath = ( file ) => path . resolve ( __dirname , '../spec/templates/' , file ) ;
3745const config = {
3846 sender : sender ,
0 commit comments