-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
89 lines (81 loc) · 2.42 KB
/
test.js
File metadata and controls
89 lines (81 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require("dotenv").config();
var Mailgen = require("mailgen");
// Configure mailgen by setting a theme and your product info
const mailGenerator = new Mailgen({
theme: "default",
product: {
// Appears in header & footer of e-mails
name: "SmartFIN",
link: "https://ourfin.tech/",
// Optional product logo
// logo: 'https://mailgen.js/img/logo.png'
},
});
const MAILGUN_API_KEY = process.env.MAILGUN_API_KEY;
const MAILGUN_DOMAIN = process.env.MAILGUN_DOMAIN;
var mailgun = require("mailgun-js")({
apiKey: MAILGUN_API_KEY,
domain: MAILGUN_DOMAIN,
});
const email = {
body: {
name: "JJ Goi",
intro:
"Here's your weekly aggregated transactions from all the different bank accounts you've linked with SmartFIN.",
table: [
{
// Optionally, add a title to each table.
title: "tBank",
data: [
{
date: "16 Nov 20 | 22:38",
description: "Automated task by SmartFIN (salary, SGD 500.0)",
amount: "$1.99",
},
{
date: "16 Nov 20 | 22:38",
description: "Automated task by SmartFIN (salary, SGD 500.0)",
amount: "$1.99",
},
],
columns: {
// Optionally, customize the column widths
customWidth: {
date: "20%",
amount: "15%",
},
// Optionally, change column text alignment
customAlignment: {
amount: "right",
},
},
},
],
action: {
instructions:
"To update your notification settings, you can click on the button below.",
button: {
color: "#22BC66", // Optional action button color
text: "Update",
link: "https://ourfin.tech/recipes/add/aggregated_email",
},
},
outro:
"Need help, or have questions? Just reply to this email, we'd love to help.",
},
};
// Generate an HTML email with the provided contents
var emailBody = mailGenerator.generate(email);
// Generate the plaintext version of the e-mail (for clients that do not support HTML)
var emailText = mailGenerator.generatePlaintext(email);
// Send
var mailOptions = {
from: "SmartFIN <hello@ourfin.tech>",
to: "jiajian.goi.2018@sis.smu.edu.sg",
subject: "[SmartFIN] Your weekly aggregated account transactions",
text: emailText,
html: emailBody,
};
mailgun.messages().send(mailOptions, function (error, body) {
console.log(body);
});