Jump to content

Archived

This topic is now archived and is closed to further replies.

trillion

phpmailer - undefined function

Recommended Posts

I am trying the tutorial here: http://www.phpfreaks.com/tutorials/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:

[code]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);[/code]
there is more under this but above is what seems relevant to the issue as I get the error at line
[code]$mailer->Body($htmlBody);[/code]

If I comment out the function body()

I get a similar error for function altbody()

what have I gotten wrong?

Share this post


Link to post
Share on other sites
OK

There was a bug in the tutorial.

here is the fix.

change:
[code]$mailer->Body($htmlBody);[/code]

to:
[code]$mailer->Body = $htmlBody;[/code]

and change:
[code]$mailer->AltBody($textBody);[/code]

to:
[code]$mailer->AltBody = $textBody;[/code]

now it works

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.