Message Body Empty

Discussion in 'PHP' started by PHPStudent, Dec 5, 2009.

  1. #1
    Guys Look at this code

    
    require_once 'class.phpmailer.php';
    
    $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
    
    $Body= "TestPay New Merchant Transaction Receipt\r\n\r\n\r\nINVOICE\r\n\r\nBelow is your transaction information  an invoice is also attached for your records:\r\n\r\nMerchant Name on Acct -$fName - $lName\r\nMerchant Name on Acct -$fName - $lName\r\nReciept Serial No. - $random_number\r\nDTG of transaction - $timestamp\r\nName of Business - $BName\r\nAddress - $Adrs\r\nCity - $Cty\r\nState - $Ste\r\nZipcode - $zpc\r\nAcct Debited  $mnysmbl 10.00 - **********$pacct\r\nInitial Product Set\r\n$proc1 - $procprc1	Shipping/Handling      $shandpr1\r\n$proc2 - $procprc2	Shipping/Handling      $shandpr2\r\n$proc3 - $procprc3	Shipping/Handling      $shandpr3\r\n$proc4 - $procprc4	Shipping/Handling      $shandpr4\r\n$proc5 - $procprc5	Shipping/Handling      $shandpr5\r\n";
    
    try {
      $mail->AddReplyTo('support@TestPay.com', 'TestPay-support-group');
      $mail->AddAddress($eml, 'NewMerchant');
      $mail->SetFrom('support@TestPay.com', 'TestPay-support-group');
      $mail->AddReplyTo('support@TestPay.com', 'TestPay-support-group');
      $mail->Subject = 'TestPay New Merchant Transaction Receipt';
      //$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
      $mail->MsgHTML(file_get_contents(''));
      //$mail->AddAttachment('invoice.doc');      // attachment
      //$mail->AddAttachment('Logo1Small.bmp'); // attachment
      $mail->Send();
      echo "Message Sent OK</p>\n";
    } catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
    }
    
    PHP:
    I keep getting "Message Body Empty" from PHPMailer - any ideas..??
     
    PHPStudent, Dec 5, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    can't you see that $mail->MsgHTML(file_get_contents('')); is empty?
     
    crivion, Dec 5, 2009 IP
  3. PHPStudent

    PHPStudent Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Guys - Is it possible to send email with PHPMailer by making the text to be sent a variable. Meaning:

    $Body="text to be sent"

    Does it have to have a file to read.

    I just made a file called "Contents.html" and modified the code to read:

    $mail->MsgHTML(file_get_contents("Contents.html"));

    and the error that came back reads - Could not instantiate mail function
     
    Last edited: Dec 5, 2009
    PHPStudent, Dec 5, 2009 IP
  4. taminder

    taminder Peon

    Messages:
    581
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    using the library?

    http://sourceforge.net/projects/phpmailer/
    Code (markup):
    or do you mean something else?
     
    taminder, Dec 5, 2009 IP
  5. PHPStudent

    PHPStudent Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yes sir using the library
     
    PHPStudent, Dec 5, 2009 IP