I have created lambda function in AWS which send mail to various recipients. I need to add company logo/banner at bottom of the mail. Below is the code
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
host: 'xxxxxx.xxxx.com',
port:587,
secure : true
});
var text = 'xxxxxxxxxx <img src="/Images/banner.jpg" width="800px" width="78%" height="100px"
height="11%" border="0" alt="Email banner">';
var mailOptions = {
from: 'donotreplyhere@xxxx.com',
to: 'skumar@xxx.com',
subject: 'Test subject',
html: text
};
exports.handler = async (event, context, callback) => {
return new Promise((resolve,reject)=>{
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log("Error " +error);
} else {
console.log('Email sent: ' + info.response);
}
});
});
}
I am receiving the mail but image is not being displayed getting error : The linked image can't be displayed.
I also tried with s3 url by uploading images in s3 bucket but using its url like
<img src="https://falcon-bucket-us-east-1-xxxxxx.s3.amazonaws.com/dev/Images/banner.jpg"
width="800px" width="78%" height="100px" "height="11%" border="0" alt="Email banner">';
But this didn't worked, may be because its not public and i can't make it public.
Any other way that i can use to accomplish this task.
Thank for looking
Here are some of the options:
CloudFront
in-front of S3 and use the CloudFront URL for the static content, do so. Here is more information.