-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (44 loc) · 1.34 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
const nodemailer = require("nodemailer");
const { google } = require("googleapis");
const OAuth2 = google.auth.OAuth2;
const config = require("./config");
const send_mail = async (text, receipient) => {
// const OAuth2_client = new OAuth2(config.clientID, config.clientSecret);
// console.log(OAuth2_client);
// console.log(config.refreshToken);
// OAuth2_client.setCredentials({
// refresh_token: config.refreshToken,
// })
console.log("done idhar tak");
// const access_token = await OAuth2_client.getAccessToken();
// console.log(access_token.token);
// console.log("error");
const transport = nodemailer.createTransport({
service: "gmail",
auth: {
type: "OAuth2",
user: config.user,
clientId: config.clientID,
clientSecret: config.clientSecret,
refreshToken: config.refreshToken,
accessToken: config.accessToken,
},
});
const mail_options = {
from: config.user,
to: receipient,
subject: "Testing email",
text: text
};
console.log("check");
transport.sendMail(mail_options, (err, data) => {
if (err) {
console.log("Send err :"+err);
console.log(data);
} else {
console.log("Email sent successfully", data);
}
transport.close();
});
};
send_mail("Greetings Everyone,\n\n\tLets see this message if ", "shewalechinmay23@gmail.com");