Embed image in email body nodemailer nodejs

Responding here in case anyone else encounters this! The __dirname above was really helpful, but this is my code to actually see the image embedded in the email My img tag: <img src=”https://stackoverflow.com/questions/48449379/cid:logo”> My attachments snippet: attachments: [{ filename: ‘Logo.png’, path: __dirname +’/folder/Logo.png’, cid: ‘logo’ //my mistake was putting “cid:logo@cid” here! }]

Node.js and Nodemailer: Can we attached PDF documents to emails?

Yes you can. You have to add the path of the file which you are trying to attach. transporter.sendMail({ from: ‘[email protected]’, to: ‘[email protected]’, subject: ‘An Attached File’, text: ‘Check out this attached pdf file’, attachments: [{ filename: ‘file.pdf’, path: ‘C:/Users/Username/Desktop/somefile.pdf’, contentType: ‘application/pdf’ }], function(err, info) { if (err) { console.error(err); } else { console.log(info); } … Read more

Nodemailer throws error Invalid login: 534-5.7.14

You might need to allow access to your Gmail account. https://accounts.google.com/b/0/DisplayUnlockCaptcha Edit (after your comment) // create reusable transporter object using the default SMTP transport transporter = nodemailer.createTransport({ host: ‘smtp.gmail.com’, port: 465, secure: true, auth: { user: ‘yourEmail’, pass: ‘yourPassword’ } }); your ‘nodemailer.createTransport’ should look something similar.

How to attach file to an email with nodemailer

Include in the var mailOption the key attachments, as follow: var mailOptions = { … attachments: [ { // utf-8 string as an attachment filename: ‘text1.txt’, content: ‘hello world!’ }, { // binary buffer as an attachment filename: ‘text2.txt’, content: new Buffer(‘hello world!’,’utf-8′) }, { // file on disk as an attachment filename: ‘text3.txt’, path: … Read more

Nodemailer/Gmail – What exactly is a refresh token and how do I get one?

Notes by this answer original’s author: So, I finally managed to figure it out. I’m surprised I couldn’t find more ressources about that so for those who need to use Gmail with Nodemailer I found the answer here: http://masashi-k.blogspot.fr/2013/06/sending-mail-with-gmail-using-xoauth2.html Try creating a new User if you already had one and things ain’t working fine. It … Read more

Sending email via Node.js using nodemailer is not working

The answer is in the message from google. Go to : https://www.google.com/settings/security/lesssecureapps set the Access for less secure apps setting to Enable For the second part of the problem, and in response to I’m actually simply following the steps from the nodemailer github page so there are no errors in my code I will refer … Read more

Sending email to multiple recipients via nodemailer

nodemailer (v2.4.2) docs say: to – Comma separated list or an array of recipients e-mail addresses that will appear on the To: field so you can just do: var maillist = [ ‘****.sharma3@****.com’, ‘****.bussa@****.com’, ‘****.gawri@****.com’, ]; var msg = { from: “******”, // sender address subject: “Hello ✔”, // Subject line text: “Hello This is … Read more