hashstar Posted May 9, 2012 Share Posted May 9, 2012 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('[email protected]', '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 https://forums.phpfreaks.com/topic/262291-help-sending-html-email-with-phpmailer/ Share on other sites More sharing options...
smoseley Posted May 9, 2012 Share Posted May 9, 2012 You have to define the mime-type as text/html. Not sure how FreakMailer handles that, but there's probably an option for it if you search online. Link to comment https://forums.phpfreaks.com/topic/262291-help-sending-html-email-with-phpmailer/#findComment-1344179 Share on other sites More sharing options...
TOA Posted May 9, 2012 Share Posted May 9, 2012 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 https://forums.phpfreaks.com/topic/262291-help-sending-html-email-with-phpmailer/#findComment-1344207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.