나는 버튼을 누르면 데이터베이스에있는 이메일에 대한 업데이트를 이메일로 보냅니다.PHP를 사용하여 여러 개의 이메일을 보내는 방법
이것은 내 코드입니다. 또한 포럼에서이있어하지만 난 그것을 데이터베이스에 이메일을하지 않는 것이 뭐가 잘못 됐는지 모르겠어요 :이 작업을 수행하는 방법에 대한
$form_action = $_POST['form_action'];
if ($form_action == 'REGISTER') {
//send to your self
$to ="[email protected]";
$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 <[email protected]>' . "\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.";
}
어떤 제안? 같은 질문으로도 도움이되지 않는 다른 주제를 살펴 보았습니다.
감사합니다.
고마워요.하지만 여전히 이해가 안갑니다. '( – bayan0926