MoreCoffeePls
MoreCoffeePls

Reputation: 21

Mail PEAR package not sending email

I've got a script set up which is supposed to email based on a query. The code is like this:

$firemail = mysql_query("SELECT `email` from `users` WHERE `reference` = ''$customer' ");
$to      = $firemail;

Ignoring the fact that this isn't PDO I then pass $firemail to smtp as follows:

$headers = array (
    'From' => $from,
    'To' => $firemail,
    'Subject' => $subject,
    'Reply-To' => '[email protected]',
    'MIME-Version' => "1.0",
    'Content-type' => "text/html; charset=iso-8859-1\r\n\r\n");
    $smtp = Mail::factory('smtp', array(
        'host' => 'smtp.myservice.com',
        'port' => '123',
        'auth' => true,
        'username' => '[email protected]',
        'password' => 'supersecretpassword'
    ));

I've tested that the SMTP works, it sends the email as designed when I manually type in the recipient. The query that $firemail contains is valid, and returns the expected result. I've echoed out the $customer var and this returns the expected result.

So assuming that all of my code is valid and operating as it should be. Why am I not receiving the email?

Thanks!

Upvotes: 0

Views: 31

Answers (1)

Hackerman
Hackerman

Reputation: 12305

This is returning a mysql object instead a result:

$firemail = mysql_query("SELECT `email` from `users` WHERE `reference` = ''$customer' ");
$to = $firemail;

Should be:

$result = mysql_query("SELECT `email` from `users` WHERE `reference` = ''$customer'");

while ($fila = mysql_fetch_assoc($result)) {
  $firemail[] = $fila['email']
}

Upvotes: 1

Related Questions