Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email opened/not tracking from nodejs nodemailer

What I know

I want to implement the email opened/not tracking in one of my websites. after searching i found that email-opened/not tracking is done by sending an embedded image along with email(typically 1 px transparent). when some one opens the email and if they allow images then we get a req for the image and we track that.

what i am using to achieve what i know

I am using MEAN stack for the project and nodemailer for sending emails with amazon ses as sending service.

Problem

I am able to send the embedded images using above technologies but the problem is in node mailer, you have to attach the image as email-attachment to embedded images. so , no call from mail client is returning to the callback-url i mentioned in image file (as email client already have the file). how do i implement it to track mail opened/not. If this cannot be done with nodemailer, please point me in the right direction.

My expertise

I am still a beginner, so kindly forgive and correct me if something above is wrong.

like image 331
raj Avatar asked Jan 22 '15 06:01

raj


1 Answers

I am not 100% sure if what i am posting is the correct way to do it but i figured out a way to make it work. Since this post did not get any valid answer all this time and i see some people viewing it i am answering my own question

You cannot track the opening of email if you send the 1px pic along with email as attachments using node-mailer as it will automatically render and send the file along with mail.(no external call made to server = you cannot detect). Render HTML using node-mailer as you do generally and input a pic with source to a route in your server like shown below

<html>
   <body>
      <img src="http://YOUR_SITE.com/track/this/image/UNIQUE_ID_FOR_THIS_IMAGE.jpg">
   </body>
</html>

Now you have no attachments in your node-mailer and the file is not sent along with email, but will be fetched to render when someone opens the email.

You can track who opened the email using the unique key in url.

P.S. Don't forget to send a (1x1)px img file back for the request. so that no 404 error occurs on the client side.

like image 145
raj Avatar answered Oct 18 '22 17:10

raj