Not Recognizing the $mail Value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bombardier

    #1

    Not Recognizing the $mail Value

    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_conn ect ("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($q uery);

    while ($row = mysql_fetch_arr ay ($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($ro w["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 ();

    }
    ?>

  • Simon Stienen

    #2
    Re: Not Recognizing the $mail Value

    On 2007-04-03 06-58-15, bombardier wrote:
    I have a PHP script that I copied and modified from the
    SourceForge.net website
    Good that there's only a single page on SourceForge.net and that you've
    given us detailed info on class phpmailer. >:]

    Regards

    Comment

    • Rami Elomaa

      #3
      Re: Not Recognizing the $mail Value

      bombardier kirjoitti:
      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.
      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...

      --
      Rami.Elomaa@gma il.com
      "Olemme apinoiden planeetalla."

      Comment

      • bobkaku

        #4
        Re: Not Recognizing the $mail Value

        On Apr 3, 1:07 am, Rami Elomaa <rami.elo...@gm ail.comwrote:
        bombardier kirjoitti:
        >
        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.
        >
        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...
        >
        --
        Rami.Elo...@gma il.com
        "Olemme apinoiden planeetalla."
        Thanks for your suggestion. I'll go post on the sourceforge forum.


        Comment

        Working...