1

I have asked a similar question to this but for GMail and I was greatly satisfied with an awesome answer I received. However, I am having trouble with another email client: Apple Mail.

I am creating my own email tracking system for email marketing tracking. I have been able to determine each persons email client they are using by using the http referrer but for some reason Apple Mail like GMail does not send across HTTP_REFERRER. For GMail the solution was to use https for where I hosted the transparent image but this hasnt worked for Apple Mail.

print_r($_SERVER); only gives this sort of header:

WM_UCONTROL_XMLRPC_SERVER - http://aaaaaaaaa

HTTPS - on

ACCESS_DOMAIN - aaaaa

DATABASE_SERVER - aaaaaaa

SITE_ROOT - /home/121000

SITE_CGIROOT - /home/121000/cgi-bin

SITE_HTMLROOT - aaaaaa

PHPRC - aaaaa

HTTP_X_FORWARDED_HOST - aaaaaaa

HTTP_X_FORWARDED_SERVER - aaaaa

HTTP_X_FORWARDED_FOR - aaaaaa

HTTP_HOST - aaaaaa

HTTP_CONNECTION - close

HTTP_USER_AGENT - Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko)

HTTP_ACCEPT - */*

HTTP_ACCEPT_LANGUAGE - en-us

HTTP_ACCEPT_ENCODING - gzip, deflate

SERVER_SIGNATURE - <address>Apache/2.2.9 Server at aaaaaaa Port 443</address>


SERVER_SOFTWARE - Apache/2.2.9

SERVER_NAME - aaaaaa

SERVER_ADDR - aaaaaa

SERVER_PORT - 443

Please note, certain details where hidden with a string of a.

Is there any other way I can find out when the Apple Mail client requests this image?

As a side note, this is when I wish SO had a way to invite certain users to questions as yc was a great help last time!

Community
  • 1
  • 1
Abs
  • 56,052
  • 101
  • 275
  • 409

2 Answers2

2
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko)

You could check to see if that user agent will match to Apple's Mail only (i.e. not Safari or other Apple WebKit implementations).

alex
  • 479,566
  • 201
  • 878
  • 984
  • 1
    This won't help him detect if the email client being used is Apple Mail. – jasonbar Feb 25 '11 at 00:21
  • Although this might work it means I have to change my current implementation. I am hoping to find out the email client just from the request of the image. I have done this for GMail, Yahoo, AOL, outlook etc and I am really hoping I can do the same for Apple Mail in the same way! – Abs Feb 25 '11 at 00:22
  • Hmm you might be onto something there. I had a look at the user agents of safari here: http://www.useragentstring.com/pages/Safari/ - and it looks like it has a version after the safari's user agent but not the Apple Mail user agent. Not sure though, anyone can confirm this is always the case?? – Abs Feb 25 '11 at 00:35
  • Actually that might not work, here is a safari user agent: http://www.useragentstring.com/Safari_id_6458.php - too similar. – Abs Feb 25 '11 at 00:36
  • @Abs You may be stuck guessing - but still, should *any* requests be coming from Safari? If not, you could assume they were from Apple Mail. If you have a *view in browser* button, be sure to add a GET param or something to invalidate the referrer. – alex Feb 25 '11 at 00:39
  • @alex I guess I can infer its apple mail by matching the OS and the browser unless they are using GMail on a safari browser on an Apple computer, but I can put the conditions in such an order to make the likelihood higher. – Abs Feb 25 '11 at 00:57
1

Here is what I would do -

  1. First, the image link for each email address should be unique. Something like pixel-.jpg. The should somehow encode the users email address.
  2. Track the user-agent that's sent as part of the http server.
  3. If you get the referrer header and can parse it, great. If not, the user-agent can help.
  4. If user-agent indicates a browser, figure out the email client from the email address. For example, if the email is abc@gmail.com, you know its web gmail.
  5. Google and other companies also provide hosted email. So, if user agent indicates a browser, and the email address is abc@mydomain.com, there is still a chance the email client is gmail. To find out more, you can look up the MX records for mydomain.com. If the MX record has google or googlemail in it, you know you are dealing with gmail. Same approach can be used for other email hosting companies.
  6. If it is a desktop based client like outlook or thunderbird, the user agent will usually indicate this.

Generally, email clients automatically block external images, so this approach will only work if the user allows image loading for your email address.

A usual trick is to have the token in an image, as well as on all links in the email. Then add a line "If you cannot view this message properly, click here". If the image is allowed, great. Otherwise the user won't be able to read your message, and will likely click the link. Either way, you get the user-agent and the hash-token.

.. But if the user doesn't allow images and doesn't click the link, there is no way to track if the user actually read the email.

Final Tip : Use the WURFL library to decode the user agent. Its the best library out there.

Sripathi Krishnan
  • 30,948
  • 4
  • 76
  • 83