Skip to content

Commit

Permalink
Mailer Somewhat Ready
Browse files Browse the repository at this point in the history
  • Loading branch information
jaison080 committed Dec 25, 2023
1 parent 35c44f8 commit 62319c9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions functions/mailer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
port: 587,
secure:false,
pool: true,
secure: false,
auth: {
user: process.env.MAILER_EMAIL,
pass: process.env.MAILER_PASSWORD,
type: "OAuth2",
user: process.env.GMAIL_EMAIL_ADDRESS,
clientId: process.env.GMAIL_API_CLIENT_ID,
clientSecret: process.env.GMAIL_API_CLIENT_SECRET,
refreshToken: process.env.GMAIL_API_REFRESH_TOKEN,
},
});

Expand All @@ -21,13 +22,10 @@ const main = async (body) => {
html: body.content,
};
await transporter.sendMail(mailOptions);
return(`Sent mail to ${body.toEmail} with subject ${body.subject}`);
return `Sent mail to ${body.toEmail} with subject ${body.subject}`;
} catch (error) {
return(
`Failed to send email to ${body.toEmail} having error : ${error}`
);
return `Failed to send email to ${body.toEmail} having error : ${error}`;
}
};


module.exports = main;

0 comments on commit 62319c9

Please sign in to comment.