Hi,

I've seen similar problems to this posted here but nothing exactly the same so apologies if this question is repeated elswehere...

I've got PHP/HTML page which shows a table of users and their e-mail addresses, retrieved from a MySQL DB. Part of the code builds the e-mail addresses returned from a query into a mailto link, in the BCC field. The user would click the link and an Outlook new message appears with the addresses in the BCC field and the subject set. Pretty simple.

This has been working fine but as the Database has got bigger I've noticed that when the results >40 recipients, I click on the link but nothing happens. No matter how big the BCC field is, if I hover over the link it shows the addresses as it should but doesnt work when there's >40ish addresses.

This is in the WHILE loop that renders the HTML Table and results:

$recps .=  $row["sm_contact1mail"]. "; ";

And this is the code for the link to be clicked on:

echo "  <a href='mailto:$sm_user@domain.com?bcc=$recps'>Click Here To Mail These Contacts></a>";

This does work for addresses up to around 30, and definitely doesnt work over 70. Has anyone seen this before and know what I'm doing wrong?
Thanks.

- Mart

The url might fail (at least in Internet Explorer) when it's longer than 2083 characters. Edit: some old versions of Firefox had this restriction too, but since at least 1.5 they supports lengths of up to 2 GB (!).

Hi, Thanks for the reply.
It's certainly going to be in the region of that sort of limit although I've tried it in Firefox and get the same problem (v4.0.1) - I've tried to build some queries that'll give me a closer target to how many addresses/characters it takes to make it not work, but I'm not close enough yet.

Is there anything else I can try?

Hmm, strange. Does SQL give you back the correct results? I mean, is the table correct? (I'll try to reproduce the bug.)

Could this be a limit imposed by your web host?

If you look at the source, is it correct?

Thanks everyone :-)

Twiss: At the moment, the Table (HTML) is using fetchrows to pull each entry/email address from SQL, I know that's not the most elegant solution but I've got the variable

$recps

within that statement to build the e-mail addresses separately, but when it works (eg with 20 entries) both the table list and the mailto code has the same recipients. I will check double check this.

When I hover over the link which generates the email with the BCC entries, I can see in the status bar of the (any) browser it shows the addresses, but obviously not all of them. (eg [email]s.smith@whereever.com,....jones@hotmail.com[/email]... ja...@gmail.com)

Chrisea: I'm not getting as far the mailhost, just the web page (internally) - MySQL Server, PHP/HTML combo.

If the code is correct, it's a problem with your email client, have you tried using another one?

Chrisea - Sorry, I read "mailhost" when you said "webhost" - It's my own webserver, on our network. I dont know of any limitation on that sort of thing, or how I'd impose it..?

Twiss: No, a good shout. I'm using Outlook 2007... I can try an alternative client for a solution, but that presents a larger problem as the whole organisation use Outlook, so I'd need to rework the method used to mail all those recipients :-/

Well, there seems to be a limit of 512 in Outlook 2003. But 40.. would be very strange. It might also be a problem with the ISP, but again, 40-70 recipients should really be no problem..

Just to update - the source of the rendered HTML does show the <mailto:> code with all the e-mail addresses in the BB field as I'd expect.

I've extracted that part of the source code and saved it to a separate html file. I'll keep chopping addresses out until it works - maybe there's a number limit, or perhaps a foreign symbol? *shrug*

Did you urlencode() the variable? ;)

Looks like 77 BCC addresses are the limit.. Here's the (rendered) HTML output (I've truncated the address, obviously)

<a href='mailto:me@domain.co.uk?bcc=dave.smith@whatever.com ; tim@domain.com;' >Click here</a>

I've noted the trailing ; from the last entry, but it's the same with or without it. I presume the mail client (Outlook) parses it out?

How many characters is that?

Including the delimiting ;'s 2089 - When I go to 2090 it doesn't work. (I just added a character into an email address (eg dave@hotmail.commmmmmmmmm) until it started working/breaking - 2090 was the limit :-(

urlencode? No! Worth a shout! How would I do that? $var = urlencode($recps) ?

Hmm... Tried

<a href='mailto:$sm_user@domain.com?bcc=urlencode($recps)'>

- still the same problem :-/

$recps = urlencode($recps);
echo '<a href="mailto:$sm_user@domain.com?bcc=".$recps.">';

This is not going to be a solution, however. You can remove the space after the delimiting ;'s, and you could remove the last one :) but that'll only 'stretch the limits' a little. As an alternative, you could just echo the BCC string, or create a button that copies that string so they can past it in their favorite email program. You can also provide them a email form, and send the email from your own server.

Definitely like the idea of clipboarding the string - Definitely gets me out of jail!
Any ideas how I can do that? (Bif of Javascript?)

You can use a flash thingy for that (http://code.google.com/p/zeroclipboard/, for example). You can also write it in pure javascript, but it would be quite a pain to make that cross-browser (IE is very easy, Safari doable, but Firefox/Opera...)

I'll check that link out - thanks :-)

No problem :)

Hmm.. I like that ZeroCB, but the test (test.html) doesnt always work in IE8 or FF 4.0.1... Do you know of any other ways? (The simpler the better!) :-P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.