Not Recognizing the $mail Value

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a PHP script that I copied and modified from the 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.


$mail = new phpmailer();

$mail->From     = "";
$mail->FromName = "List manager";
$mail->Host     = "";
$mail->Mailer   = "smtp";

$dbh=mysql_connect ("localhost", "mydb", "password") or die ('I cannot
connect to the database because: ' . mysql_error());
$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;

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

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

        echo "There has been a mail error sending to " .
$row["email"] . "<br>";

    // Clear all addresses and attachments for next loop


Re: Not Recognizing the $mail Value

On 2007-04-03 06-58-15, bombardier wrote:

Quoted text here. Click to load it

Good that there's only a single page on and that you've
given us detailed info on class phpmailer. >:]


Re: Not Recognizing the $mail Value

bombardier kirjoitti:
Quoted text here. Click to load it

You claim that the problem is that $mail is not recognized, however this  
is not very likely the reason. If in fact something nullified $mail,  
you'd get an error saying something like you undefined method called for  
non-object or something. Clearly it works, but there is something  
happening with Send() that fails and your script is actually working  
correctly in displaying the error message. You need to find what is  
stopping Send() form sending. Does mail() work okay? Also, you should be  
asking this at sourceforge forums, not here...

"Olemme apinoiden planeetalla."

Re: Not Recognizing the $mail Value

Quoted text here. Click to load it

Thanks for your suggestion.  I'll go post on the sourceforge forum.

Site Timeline