50

There is a maximum length for the text in the &body section of a mailto: link. According to one of my co-workers, the W3C publish the limit as 256 (I don't have a link to back this up, though).

We're embedding mailto: links in both an e-mail and a webpage and have successfully used more than 256 characters. After a certain point, though, e-mail clients and browsers start flaking out and refusing to open the link.

I would like to know the actual maximum lengths allowed for the following:

Mail clients:

  • Outlook (2003, 2007, 2010)
  • Eudora (7.1, and/or whatever the latest version is)
  • Thunderbird (latest version)

Browsers:

  • Firefox (3+)
  • IE (6, 7, 8)
  • iPhone browser

Any and all numbers you can provide will be gratefully received.

Brian Beckett
  • 4,742
  • 6
  • 33
  • 52
  • https://stackoverflow.com/a/33041454/1133275 – user1133275 Oct 10 '17 at 15:46
  • This question has been posed several times on StackOverflow over the years without an acceptable answer. Server-side solution may be feasible for everyone. I posted a solution here https://stackoverflow.com/a/74778578/3297640 – Vijay Jagdale Dec 12 '22 at 23:56

4 Answers4

35

The standard doesn't define a maximum length, leaving implementation up to browsers and mail clients (See IETF RFC 2368).

Microsoft products do have set limits:

Other browsers are likely to work up to lengths beyond that of a reasonable email body. The iPhone doesn't have a documented limit, but works with up to 1MB of text.

Modern browsers that support data urls (everything except IE<9) should be fine.

jlev
  • 614
  • 7
  • 8
  • 4
    Link to iPhone mailto length test: http://www.benzado.com/blog/post/28/iphone-openurl-limit – jlev Jul 07 '11 at 00:23
  • 1
    Thank you. It's a shame that there's not more information out there about mailto lengths, but what you've given me is better than the nothing I had before :) – Brian Beckett Jul 21 '11 at 20:31
  • Note that the latest release of "Microsoft Outlook Express" was 2001 then it was renamed to Windows Mail/Windows Live Mail, im unsure if those have the same limitation. – Peter Feb 13 '14 at 14:37
  • 2
    In my IE10, a mailto link with length 2054 fails, while one with length 2045 works. – Cees Timmerman Sep 03 '14 at 08:27
16

For browsers with JS consoles, an easy test:

for (var i=2014; i>1600; i--) {var good=1; try {location.href='mailto:?body='+'a'.repeat(i)} catch (e) {good=0;} if (good==1) {console.log(i+13);break;}}

(The 13 is for the length of mailto:?body=.)

On Firefox 32.0.3 this produces 2008 (body length 1995). On Thunderbird 31.2.0, all 1,995 characters make it into the body of the new e-mail.

Some say it's mainly OS-setting-dependent but on Windows, at least, I couldn't find any registry entry related to mailto with a number near 2,000.

Kev
  • 15,899
  • 15
  • 79
  • 112
  • This script did not work for me. In Chrome and Firefox, it simply prints whatever the starting value of `i` is, plus 13. Even if the number is so large that the page itself runs out of memory. – JHS Jul 14 '15 at 18:52
  • @JHS, verified your result on Linux with latest FF. I guess an update broke my testing method, i.e. trying to set `window.location` to too long a URL does not throw an error like it did at the time of posting. – Kev Jul 15 '15 at 00:59
  • I was on Ubuntu 14.04 and tried it in Firefox and Chrome, then on a VM of Windows 10 with IE and Edge / Spartan. I tried to find the limit by putting very large numbers in your original script (starting small and working up). Chrome ran out of memory and showed the "dead page" screen, whereas Firefox kept chugging along until the process stopped responding. For the most part, the hard limits seem enforced only by certain mail clients, such as Outlook. I don't doubt that your script worked at the time you wrote it. The browsers probably used to have URL length limits. – JHS Jul 15 '15 at 01:11
  • On Chrome your script gave 2027. So clever. – Chloe Oct 09 '17 at 18:57
6

As of 2022 it seems outlook (2007 anyway) accepts long query_string of at least 8000 characters using mailto in Firefox. However using Google Chrome browser, Chrome failed right around 2000. Lowest common denominator seems to be Chrome. Too bad since this has been a request for over a decade.

denpick
  • 71
  • 1
  • 2
1

I just did an experiment from Wolfram Mathematica to Microsoft Outlook. It works for string lengths of 31888 or less. This is the code I used for this experiment:

Table[ToString@RandomInteger[{0, 9}], 31433] //
     Partition[#, UpTo[80]] & //
    Map[StringJoin] //
   StringRiffle[#, "\n"] & //
  "mailto:xxxxxxx.xxxxxxx@xx.com?subject=Testing out mailto!&body="<> # & //
 Echo[#, "Total String Length", StringLength] & //
SystemOpen

and prints 31888 as the total string length. If you increase the 31433 by one, it stops working.

gdelfino
  • 11,053
  • 6
  • 44
  • 48