开发者

Hundreds of emails in MailTo - Outlook/Windows?

Basically I have a table in my database of contacts. It has an email address assigned to each user.

I'm trying to create a button which, when clicked, does a mailto in the Bcc field of a new email, populated from the entire table's entries:

mailto:?bcc=<?php 
  while($rows=mysql_fetch_array($result))
  { 
    echo $rows['EMAIL']开发者_运维问答; 
    echo ", "; 
  } 
  mysql_close(); ?>

It works great on Firefox/MacMail on my Mac, but when I try with Internet Explorer/Outlook on Windows nothing happens (i.e. I click the button but it doesn't open a new Outlook message).

Any ideas?


Both Internet Explorer (maximum of 2,083 characters, see KB208427) and Outlook (similar number of characters, I can't find an authoritative reference) have maximum URL lengths they can process. If you have hundreds of email addresses, you'll easily reach these limits.


There is a problem in your code, the list of emailadresses always ends with an extra ,.
I would get rid of that.

Also I suggest you do all the work in the database, rewrite the code to something like:

<?php
$param = mysql_real_escape_string($_POST['param']);
$query = "SELECT GROUP_CONCAT(email) as emailadresses 
          FROM email WHERE afield = '$param' ";
?>

mailto:?bcc=
<?php 
  $rows=mysql_fetch_array($result));
  echo $rows['EMAIL']; //no while loop needed, group_concat does all the work.
  mysql_close(); 
?>

See: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜