Jump to content


Photo

phpmailer - undefined function


  • Please log in to reply
2 replies to this topic

#1 trillion

trillion
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 27 September 2006 - 07:43 PM

I am trying the tutorial here: http://www.phpfreaks...rials/130/0.php
to set up php email using phpmailer.

It works fine for basic text email but when I get to the part to add html body content I get this error:

Fatal error: Call to undefined function: body() in /home/user/public_html/dir/dir/mailto-html.php on line 21

the code looks like this:

require_once('../config.php');
require_once('MailClass.inc');

$mailer = new IDMailer();

$mailer->Subject = 'This is a Test';

$htmlBody = '
<html><head><title>HTML Tst Ml</title></head><body>
<img src="http://phpfreaks.com/images/phpfreaks_logo.php" /><br />
<h2>PHP Rocks!</h2>
<p>We text text text text text text text text text text text text
<a href="http://inherentdesign.com>ID</a> 
text text text text text</p>
';

$textBody = 'Hopefully I will not see this';

$mailer->Body($htmlBody);
$mailer->isHTML(true);
$mailer->AltBody($textBody);
there is more under this but above is what seems relevant to the issue as I get the error at line
$mailer->Body($htmlBody);

If I comment out the function body()

I get a similar error for function altbody()

what have I gotten wrong?

#2 trillion

trillion
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 28 September 2006 - 02:32 AM

OK

There was a bug in the tutorial.

here is the fix.

change:
$mailer->Body($htmlBody);

to:
$mailer->Body = $htmlBody;

and change:
$mailer->AltBody($textBody);

to:
$mailer->AltBody = $textBody;

now it works

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 28 September 2006 - 11:38 AM

Thanks for the update Trillion.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users