How to change the “from” field in nodemailer?
The from field has to be in the the format Display Name <[email protected]> transporter.sendMail({ …, from: ‘Foo from @bar.com <[email protected]>’ });
The from field has to be in the the format Display Name <[email protected]> transporter.sendMail({ …, from: ‘Foo from @bar.com <[email protected]>’ });
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! }]
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
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.
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
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
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
From the heroku doc: The logs command retrieves 100 log lines by default. You can specify the number of log lines to retrieve (up to a maximum of 1,500 lines) by using the –num (or -n) option. $ heroku logs -n 200 So probably you need to request more lines with -noption. As per comment … Read more
You have auth: { user: ‘user@gmail.com’, password: ‘password’ } But you should write this auth: { user: ‘user@gmail.com’, pass: ‘password’ } Just rename password to pass.
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