利用PHP怎么查询E-mail地址

今天就跟大家聊聊有关利用PHP怎么查询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>

看完上述内容,你们对利用PHP怎么查询E-mail地址有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。