我目前正在研究一個php mysql基本系統,將從功能上覆選框從數據庫發送電子郵件給多個收件人。使用phpMailer發送電子郵件到多個收件人從數據庫使用複選框使用複選框到選定的電子郵件地址
如何使用檢查所有功能向那些收件人發送電子郵件?
這裏是我的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 = '[email protected]';
$mailer->Password = 'mypassword';
$mailer->From = '[email protected]';
$mailer->FromName = 'Admin';
$mailer->Body = 'TEST EMAIL';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('[email protected]');
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*/
?>
如果您能夠檢索到顯示在複選框列表中的電子郵件地址列表,那麼您已經擁有幾乎所有您需要的東西。表單提交所選電子郵件地址的id(或其他),並將郵件發送給他們... –