当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP批量查询WordPress留言者E-mail地址实现方法

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

2018年07月03日  | 移动技术网IT编程  | 我要评论

今天收到了很多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好了啦 :)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网