Jump to content

Help sending html email with phpMailer


hashstar

Recommended Posts

Hi there,

 

i am trying to send a html using phpMailer and am following this tutorial: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html

 

 

I have managed to send an email just fine but when i try to add html to it it doesn't work! I get this message:

 

Mail sent!

Fatal error: Call to undefined method FreakMailer::Body() in /hermes/waloraweb018/b1267/moo.organicgrowshopcouk/testemail.php on line 44

 

 

This is the code I'm using:

 

 

 

<?php

 

// Grab our config settings

require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');

 

// Grab the FreakMailer class

require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc');

 

// instantiate the class

$mailer = new FreakMailer();

 

// Set the subject

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

 

// Body

$mailer->Body = 'This is a test of my mail system!';

 

// Add an address to send to.

$mailer->AddAddress('info@organicgrowshop.co.uk', 'Matt Johnson');

 

if(!$mailer->Send())

{

    echo 'There was a problem sending this mail!';

}

else

{

    echo 'Mail sent!';

}

$mailer->ClearAddresses();

$mailer->ClearAttachments();

 

$htmlBody = '<html>

<head>

<title>My HTML Email</title>

</head>

<body>

<br />

<h2>PHP Freaks Rules!</h2>

<p>We invite you to visit <a href="http://www.phpfreaks.com" title="PHP Freaks">PHP Freaks.com</a> for a loving community of PHP Developers who enjoy helping each other learn the language!</p>

 

<p>Sincerely,<br />

PHP Freaks Staff</p>';

 

$mailer->Body($htmlBody);

$mailer->isHTML(true);

 

// Send the E-Mail

?>

 

 

 

 

 

 

How do i define method Body()  ?  Do i need to change something in the phpmailer.class.php file? 

 

Sorry if i sound like a complete n00b.

Link to comment
Share on other sites

Body is not a method, it's a property. Access it as such (like you do previously in your script).

 

Spot a difference?

 

// Body

$mailer->Body = 'This is a test of my mail system!';

 

<< stripped >>

 

$mailer->Body($htmlBody);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.