-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
109 lines (92 loc) · 2.51 KB
/
app.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"use strict";
const niceInvoice = require('./nice-invoice/app.js');
const nodemailer = require('nodemailer');
const invoiceDetail = {
niceInvoice: {
prakarsh_logo: "prakarsh1.png"
},
shipping: {
name: "Jay Patel",
college: "Sardar Vallabhbhai Patel Institute of Technology, Vasad",
mobile: "+91-9879726851",
email: "[email protected]",
},
items: [
{
item: "Computer Workshop",
price: 30.00,
tax: ""
},
{
item: "Aero Workshop",
price: 50.00,
tax: ""
},
{
item: "Engine Evolution",
price: 50.00,
},
{
item: "Computer Workshop",
price: 30.00,
tax: ""
},
{
item: "Aero Workshop",
price: 50.00,
tax: ""
},
],
total: 130,
order_number: "",
payment_id: "",
order_id: "order-54464",
header: {
company_name: "Prakarsh XVI",
company_logo: "prakarsh.png",
company_address: "Sardar Vallbhbhai Patel Institute of Technology\nSVIT Road, \nRajupura Village,\nAnand 388306"
},
footer: {
text: "Copyright © Prakarsh XVI\n www.prakarsh.org"
},
currency_symbol: "",
date: {
billing_date: "08 August 2020",
}
};
async function main(pdfData) {
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
name: "gmail.com",
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: '', // email
pass: '', // generate app password
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Jay Patel" <[email protected]>', // sender address
to: "[email protected], ", // list of receivers
subject: "[Prakarsh 2021] Here is your receipt🎉", // Subject line
text: "", // plain text body
attachments: [
{
filename: "Invoice.pdf",
content: pdfData,
encoding: "base64"
}
]
});
console.log("Message sent: %s", info.messageId);
// Message sent: <[email protected]>
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
niceInvoice(invoiceDetail, main);
// main().catch(console.error);