SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    845
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    A question about configuring phpMailer

    Here is a snip of code that is causing me problems. Earlier in the code it queries the database and retrieves two emails. One row has a format = Plain and the other row has a format = HTML, for testing purposes. The line of code giving me grief is $mail->MsgHTML($body); If I use "This is <b>bold</b> test" instead of $body then it works fine. I do have a very simple testEmail.html in the same directory as this PHP script, so that is not the problem. Can you see anything else that may be causing the SMTP error to show, "Mailer Error () Message body empty" ?

    Thanks!

    PHP Code:
    if ($row[format] == "Plain") {        

    $mail->Body $row["message"];    

    } else {

    $body file_get_contents('testEmail.html');
    $body preg_replace('/[\]/','',$body);

    $mail->MsgHTML($body);
    $mail->AltBody "To view the message, please use an HTML compatible email viewer!";

    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Why not simply echo or var_dump the $body variable onto the page prior to evoking Mailer and inspect the values?

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    845
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you. I got it worked out.
    Convert your dollars into silver coins. www.convert2silver.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •