Any help would be much appreciated. Here is the code:
<?php include 'header_admin.php'; ?>
<?php
include 'dbc.php';
page_protect();
checkAdmin();
?>
<?PHP
require_once "Mail.php";
$con = mysql_connect("host","username","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
$elist = mysql_query("SELECT cEmail FROM tblUsers WHERE intUserID = '20'");
$from = "FROM E-MAIL";
$subject = $_POST['eSubject'];
$body = $_POST['eMessage'];
$host = "smtp.domain.com";
$port = "465";
$username = "username";
$password = "password";
echo "<div class='entry'>";
if(mysql_num_rows($elist) > 0)
{
while($eresult = @mysql_fetch_array($elist)) {
$headers = array ('From' => $from, 'To' => $eresult['cEmail'], 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($elist_result['cEmail'], $headers, $body);
}
}
echo "<table align='center'><p>Message successfully sent!</p></table></div>";
mysql_close($con);
?>
I made sure that the smtp settings were correct and I manually checked my mysql query to make sure it's grabbing the e-mail address. also, I did a separate "echo" command to make sure $body and $subject were correct.