我目前正在开发一个 php mysql 基础系统,该系统将在功能上使用复选框从数据库向多个收件人发送电子邮件。
如何使用检查所有功能向这些收件人发送电子邮件?
这是我的 phpMailer 代码,工作正常
<?php
require("class.phpmailer.php");
include("class.smtp.php");
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.gmail.com:465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'myemail@gmail.com';
$mailer->Password = 'mypassword';
$mailer->From = 'myemail@gmail.com';
$mailer->FromName = 'Admin';
$mailer->Body = 'TEST EMAIL';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('myrecipient@yahoo.com');
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
我目前在系统中使用的另一个示例代码,用于从具有复选框功能的数据库中删除用户:
<?php
/*Check Box Commands*/
$id=$row_notification['user_id'];
if(isset($_POST['Delete'])) {
$checkbox = $_POST['checkbox'];
mysql_select_db($database_connection_ched, $connection_ched);
$id=$row_notification['user_id'];
for($i=0;$i<count($checkbox);$i++)
{
$delete = "DELETE FROM tb_user WHERE user_id=$checkbox[$i]";
mysql_query($delete,$connection_ched);
}
$result2 = mysql_query($delete);
if($result2)
{
echo "<script language='javascript'>alert ('Successfully Deleted');</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=notification.php?\">"; }
}
/*End of Checkbox Commands*/
?>