18

I have a mailto link in an anchor tag

<a href="mailto:?subject=Subject&body=Body">Email This</a>

The issue is that the Body parameter is a huge article, and there appears to be a character limit on the url.

Is there a way to get around the limit?

bzlm
  • 9,626
  • 6
  • 65
  • 92
HyderA
  • 20,651
  • 42
  • 112
  • 180
  • 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:58

4 Answers4

14

Is there a way to get around the limit?

Very hardly.

It is even probable that the limitations vary from browser to browser, or from E-Mail client to E-Mail client.

I would rather use a HTML form and a server-side script to send the message.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • I don't want to email the message. I want it to work like a regular mailto link, where the user can send an email via their mail client. – HyderA Nov 01 '10 at 08:21
  • @gAMBOOKa I see. You may be out of luck for that... Maybe send a link to the information instead? – Pekka Nov 01 '10 at 08:24
  • Yes, i guess an excerpt and a link will have to do. Thanks! – HyderA Nov 01 '10 at 08:26
7

Yes, there is a limit on the length of the URL.

The limit varies from browser to browser, so you should keep the URL below 2000 characters to be safe.

Internet Explorer seems to be the browser that is having the shortest limit. According to this article it's 2083 characters.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • 1
    This also holds for href="" which was a problem for my href="javascript: new Array(.....)" (very long array) – Spork Jul 02 '13 at 15:28
0

Yes there are issues with Mailto tag it varies from browser to browser and email client to email client . In case of this issues try server side script to overcome this issue . Mailto at times behaves very abnormal

  • 1
    The answer seems similar to others that are already posted and is not very useful. Do you have more details to add? – VKen Oct 10 '12 at 18:25
-2

I know this question is old, but I had a similar problem, hitting the limit as I needed to send the email into many recipients.

I came across this solution, but I don't understand why it works, I leave it here anyway

function sendEmails(emails) {
  var timeout = 2000;
  var mailtoPrefix = 'mailto:?bcc=';
  var maxUrlCharacters = 1900;
  var separator = ';';
  var currentIndex = 0;
  var nextIndex = 0;

  if (emails.length < maxUrlCharacters) {
    window.location = mailtoPrefix + emails;
    return;
  }

  do {
    currentIndex = nextIndex;
    nextIndex = emails.indexOf(separator, currentIndex + 1);
  } while (nextIndex != -1 && nextIndex < maxUrlCharacters)

  if (currentIndex == -1) {
    window.location = mailtoPrefix + emails;
  } else {
    window.location = mailtoPrefix + emails.slice(0, currentIndex);
    setTimeout(function () {
      sendEmails(emails.slice(currentIndex + 1));
    }, timeout);
  }
}

usage:

var emails = 'a@a.com;b@b.com;c@c.com';
sendEmails(emails);
Nick
  • 1,417
  • 1
  • 14
  • 21
  • 3
    It works by splitting the emails listed in `mailto` if the url is too large and calling `mailto` manually for each sliced set of emails. This only works if there are too many emails (as opposed a large body asked in the original questions) and it creates multiple email drafts in the mail client. – HyderA Feb 02 '18 at 20:40
  • No, it will create multiple emails with body parts. – HyderA Feb 06 '18 at 16:43