Permalink
Browse files

cid corrections

  • Loading branch information...
1 parent b494262 commit bc62c5a9b73c79b304a50dd0c7784a4b96e20eba andris9 committed Jan 21, 2011
Showing with 8 additions and 3 deletions.
  1. +3 −1 README.md
  2. +5 −2 examples/example.js
View
@@ -102,7 +102,9 @@ Attachments can be used as embedded images in the HTML body. To use this feature
of the attachment - `cid` (unique identifier of the file) which is a reference to the attachment file.
The same `cid` value must be used as the image URL in HTML (using `cid:` as the URL protocol, see example below).
- var cid_value = "unique-image-cid";
+**NB!** the cid value should be as unique as possible!
+
+ var cid_value = Date.now()+".image.jpg";
var html = 'Embedded image: <img src="cid:'+cid_value+'" />';
var attachments = [{
filename: "image.png",
View
@@ -12,14 +12,17 @@ nodemailer.SMTP = {
pass: ""
}
+// unique cid value for the embedded image
+var cid = Date.now()+".image.png";
+
// Message object
var message = {
sender: 'Example Test <test@example.com>',
to: '"My Name" <mymail@example.com>',
subject: "Nodemailer is unicode friendly ✔",
body: "Hello to myself!",
- html:"<p><b>Hello</b> to myself <img src=\"cid:unique-id-of-the-image\"/></p>",
+ html:"<p><b>Hello</b> to myself <img src=\"cid:"+cid+"\"/></p>",
attachments:[
{
@@ -31,7 +34,7 @@ var message = {
contents: new Buffer("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/"+
"//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U"+
"g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC", "base64"),
- cid: "unique-id-of-the-image"
+ cid: cid
}
]
}

0 comments on commit bc62c5a

Please sign in to comment.