jeudi 13 novembre 2014

Email application


Vote count:

0




I am trying to make a simple application to send out emails to the email addresses in my database. Im using phpmailer. this line is not working $mail->AddAddress($to, "Test Message"); It only works if instead of $to i type an email address but I need to send emails to every email in the database.



if ((!empty($subject)) && (!empty($text))) {


$query = "SELECT * FROM email_list";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');

while ($row = mysqli_fetch_array($result)){

$to = $row['email'];
$mail->AddAddress($to, "Test Message");
$subject = $_POST['subject'];
$text = $_POST['elvismail'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$msg = "Dear $first_name $last_name,\n$text";
mail($to, $subject, $msg, 'From:' . $from);
echo 'Email sent to: ' . $to . '<br />';
}

mysqli_close($dbc);


}



asked 46 secs ago







Email application

Aucun commentaire:

Enregistrer un commentaire