You are here: Not Recognizing the $mail Value « PHP Programming Language « IT news, forums, messages
Not Recognizing the $mail Value

Posted by bombardier on 04/03/07 04:58

I have a PHP script that I copied and modified from the
SourceForge.net website that I cannot get to work. The problem seems
to be that the value for $mail is not recognized. The script fails
at the if(!$mail-> Send() ) and the unsuccessful message goes out.
Can somebody see what is wrong here? Thanks in advance.

<?
require("class.phpmailer.php");


$mail = new phpmailer();

$mail->IsMail();
$mail->From = "list@mydomain.com";
$mail->FromName = "List manager";
$mail->Host = "smtp.site.com";
$mail->Mailer = "smtp";

$dbh=mysql_connect ("localhost", "mydb", "password") or die ('I cannot
connect to the database because: ' . mysql_error());
mysql_select_db("mydb_mytable");
$query = "SELECT fname, lname, email from mytable";
$result = @MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
$fullname = $row["fname"] . " " . $row["lname"];

// HTML body
$body = "Hello <font size=\"4\">" . $fullname . "</font>, <p>";
$body .= "Here's the message." <br>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello <font size=\"4\">" . $fullname . ", \n\n";
$text_body .= "Here's the messsage. \n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"]);

echo "The message:" . $mail. "<br>";

echo "Here's the message." . "<br>" . $body;


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();

}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация