Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何使用php发送多封电子邮件_Mysql_Php - Fatal编程技术网

Mysql 如何使用php发送多封电子邮件

Mysql 如何使用php发送多封电子邮件,mysql,php,Mysql,Php,我有一个按钮,当按下时,它会通过电子邮件更新数据库中的电子邮件 这是我的密码。我也从一个论坛上得到了这个,但我不知道是什么错,它没有收到数据库中的电子邮件: $form_action = $_POST['form_action']; if ($form_action == 'REGISTER') { //send to your self $to ="admin@admin.com"; $subject = 'System Email'; // message $message = "&l

我有一个按钮,当按下时,它会通过电子邮件更新数据库中的电子邮件

这是我的密码。我也从一个论坛上得到了这个,但我不知道是什么错,它没有收到数据库中的电子邮件:

$form_action = $_POST['form_action'];
if ($form_action == 'REGISTER') {

//send to your self
$to ="admin@admin.com";

$subject = 'System Email';

// message
$message = "<html>".
"<head>".
" <title>System Email</title>".
"</head>".
"<body>".
"message here!".
"</body>".
"</html>";

//get email list

//open database connection
$username = "root";
$password = ""; //input your password here.
$database = "dbase";
//connect to database
$link=mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("<b>Unable to specified database</b>");

$query="SELECT email_address FROM db_other_details";
$result=mysql_query($query) or die('Error, query failed');
mysql_close($link);

$row=1;
$numrows=mysql_num_rows($result);
$bccfield="Bcc: ". mysql_result($result,0,"email_address");
while($row<$numrows)
{
$email=mysql_result($result,$row,"email_address");
$bccfield .= "," . $email; //seperate by comma 
$row++;
}
$bccfield .= "\r\n";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= $bccfield;

$headers .= 'From: System <admin@admin.com>' . "\r\n";

// Mail it
mail($to, $subject, $message,$headers);

 if (mail($to,$subject,$message,$headers)) {
   header("Location: ".WEBSITE_URL."email-all.html?result=success");
} else {
    header("Location: ".WEBSITE_URL."email-all.html?result=failed");
}
}

switch (trim($_GET['result'])) {
    case "failed":
        $sendmail_result    = "failed";
        $form_message       = "Cannot send email to " . $numrows . "registrants at this time. Please try again later.";
        break;
    case "success":
        $sendmail_result    = "success";
        $form_message       = "Email sent to" . $numrows ." registrants.";
}
$form\u action=$\u POST['form\u action'];
如果($form_action=='REGISTER'){
//发送给你自己
$to=”admin@admin.com";
$subject='系统电子邮件';
//信息
$message=”“。
"".
“系统电子邮件”。
"".
"".
“这里有留言!”。
"".
"";
//获取电子邮件列表
//开放数据库连接
$username=“root”;
$password=”“;//在此处输入您的密码。
$database=“dbase”;
//连接到数据库
$link=mysql\u connect(localhost,$username,$password);
@mysql_select_db($database)或die(“无法指定数据库”);
$query=“从db\U其他\U详细信息中选择电子邮件地址”;
$result=mysql_query($query)或die('Error,query failed');
mysql_close($link);
$row=1;
$numrows=mysql\u num\u行($result);
$bccfield=“Bcc:.mysql\u结果($result,0,“电子邮件地址”);

而($row您应该尝试以下备选方案

1)使用PDO

2) 确保您在php上有错误消息

3) var\u dump/print\r您的变量&获取请求以查看数据是否可用

4) 检查mysql错误日志以了解潜在的查询错误


5) UTF-8在使用php::mail()函数发送数据之前对数据进行编码。

谢谢……但我还是不明白:'(