I'm trying to use phpmailer and a database. here's the script that i have formulated to get the message and subject, fromname, and addresses of recepients.
I want to get the list of emails from the database, add them to an array, and send the email. When i get the list from the database and echo it, it just says ARRAY. What can I do?
<?php
//processing the mass email form.
require("class.phpmailer.php");
include '../includes/connect.php';
include '../includes/pass.inc.php';
//put all of the selected addresses into an array called email
$name = $_POST['fromname'];
$fromadd = $_POST['from'];
$body = $_POST['body'];
$subject = $_POST['subject'];
$name = htmlspecialchars($name, ENT_NOQUOTES);
$fromadd = htmlspecialchars($fromadd, ENT_NOQUOTES);
$subject = htmlspecialchars($subject, ENT_NOQUOTES);
$body = htmlspecialchars($body, ENT_NOQUOTES);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->From = $fromadd;
$mail->FromName = $name;
$mail->Host = "mail.truman.edu";
$query = "SELECT email FROM brothers";
$result = mysql_query($query);
//$adds = file('addresses.txt'); // read the addresses file into an array
//foreach($adds as $address) // loop through the array adding the email addresses to the mailer
/*gets one address, then sends email, and clears address, and gets next.
while ($row = mysql_fetch_array ($result))
{
// Plain text body (for mail clients that cannot read HTML)
$mail->Body = $body;
$mail->Subject = $subject;
$mail->From = $fromadd;
$mail->FromName = $FromName;
$mail->AddAddress($row['email']);
if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
}*/
header("location: [url]http://dsp.truman.edu/email/success.php[/url]");
?>