I am developing an AWS lambda function using node.js 14.x for my runtime.
I create a nodemailer layer and upload it to my lambda function. I am trying to test my function and just return a simple console log but I don't see the console log anywhere including my cloud watch logs.
exports.handler = async (event) => {
// TODO implement
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
// user: process.env.USER_NAME,
// pass: process.env.EMAIL_PASS,
user: "********",
pass: "********",
},
});
const mailOptions = {
from: "taxs@gmail.com",
to: "trdmon@gmail.com",
subject: "subject",
text: "message",
};
transporter.sendMail(mailOptions, function (error, info) {
console.log('hit')
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
}
});
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
If the transporter.sendEmail function were running I should see the console log. Any ideas why my function isn't running?