Hi can someone help me about sending a email with the array data I gathered? I'm trying to fetch records on the DB using array and then I'll email it
Here's my code: I will get the records I want first:
$queclient_credit = "SELECT company, credits FROM clients WHERE credits <= 20 and company !='' ORDER BY credits ASC ";
$getque = mssql_query($queclient_credit) or die();
while ($rowclient_credit=arrayfetch($getque)){
$rowcompany = $rowclient_credit['company'];
$rowcredits = $rowclient_credit['credits'];
Then put it on array:
$data = array(
'company'=>$rowcompany,
'credits'=>$rowcredits
);
$dat = implode(' : ', $data);
}
if($rowcredits<= 20){
$from='email@gmail.com';
$to = 'email@gmail.com';
$gmailPass = 'password';
require('phpmailer/5.1/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = 'smtp.gmail.com';
$mail->Port = '465';
$mail->Username = $from;
$mail->Password = $gmailPass;
$mail->From = $from;
$mail->FromName = $from;
$mail->AddReplyTo($from, $from);
$mail->Subject = 'Credit System ';
$mail->Body = $message;
$mail->MsgHTML('<b><p>'.$dat.' credits<p><b>');
$mail->IsHTML(true);
$mail->AddAddress($to, $to);
if(!$mail->Send()){
// $mail->ErrorInfo;
}else{
echo 'Message Successfully Sent!';
$mail->ClearAddresses();
$mail->ClearAttachments();
}
}
Thank you for who will answer