PHP批量查询WordPress留言者E-mail地址实现方法

  今天收到了很多Bloger朋友的E-mail拜年短信,嘿嘿,感觉很好玩,可是他们是如何实现的这个呢,很简单的,可是简单的分为两步:

  1)通过SQL查询获取E-mail地址

  2)通过某种方法群发E-mail

  对于1,几行PHP代码可以解决:

  

复制代码 代码如下:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html

  xmlns="http://www.w3.org/1999/xhtml">

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>WordPress 邮件群发工具 Designed By Kaisir</title>

  </head>

  <body>

  <?php

  //要连接的数据库地址

  $db_server="localhost";

  //数据库用户名

  $db_user_name="这里改成你的数据库用户名";

  //数据库密码

  $db_user_password="这里改成你的数据库的密码";

  //数据库名

  $db_name="这里改成你的数据库名";

  //以下代码请不要修改

  $sql="SELECT DISTINCT comment_author_email FROM `blog_comments` WHERE 1";

  $conn=mysql_connect($db_server,$db_user_name,$db_user_password);

  if(!$conn)

  {

  echo"<p align=center>数据库连接失败!请检查用户名密码!</p>";

  exit(0);

  }

  $flag=mysql_select_db($db_name,$conn);

  if(!$flag)

  {

  echo"<p align=center>数据库连接正常,但无法打开指定的数据库!</p>";

  exit(0);

  }

  //执行查询

  $result=mysql_query($sql,$conn);

  while($row=mysql_fetch_array($result))

  {

  ?>

  <?echo $row["comment_author_email"]?>,

  <?php

  }

  mysql_close($conn);//关闭数据库连接

  ?>

  </body>

  </html>

  对于2,这个就比较麻烦了……因为那么大数据量的邮件任何一个邮件服务商都会把你屏蔽掉的,所以最好的办法就是自己搭建SMTP服务器,或者使用群发工具,嘿嘿,这个就由大家自己Google好了啦 :)