Mailer Error () Message body empty

Hi I am new to programming and was trying to figure out how to send newsletters. I learned the best way forward is using PHPmailer.

Below is the code which I am trying and getting "Mailer Error () Message body empty". I also tried using $body = "this is text subject".. but didn't worked. I am using php version 5.4.3 and phpmailer version 5.2.4

First and foremost, if you are new to PHP stop what you are doing. Copying someone else's bad code from online sources will (did) get you into trouble. The MySQL extensions are deprecated. Don't use them. Learn PDO and switch to it and use prepared statements.

Second, to your problem, if you echo '$body' right after you set it up, do you get what you expected? You need to read ManiacDan's New User Guide. It addresses various debugging techniques for problems like yours.

There are 10 kinds of people in the world. Those that understand binary and those that don't.

Copying someone else's bad code from online sources will (did) get you into trouble. The MySQL extensions are deprecated.

I haven't copied the code from any site.. I am using the code from examples given in PHPmailer version 5.2.4. As this is latest version of PHPmailer (released on 19th Feb 2013), I don't think it contains any deprecated functions.

Example and tutorial writers do the forum denizens of the world no favors by omitting error checking and handling, as clueless n00bs copy and paste their example code with no concept of this very important facet of programming, leaving the hapless volunteers in said forums to clean up the mess.

I ♥ ManiacDan & requinix

This is a sig, and not necessarily a comment on the OP:Please don't be a help vampire!

Example and tutorial writers do the forum denizens of the world no favors by omitting error checking and handling, as clueless n00bs copy and paste their example code with no concept of this very important facet of programming, leaving the hapless volunteers in said forums to clean up the mess.

I don't think you know about PHPmailer and that's why instead of solving the problem, you are blaming writers and talking like spoilt kid.

In the meantime I have figured out the solution on my own...

Comments on this post

ptr2void disagrees
: My years of experience dating back to writing extensions for PHP 3 beg to differ with you.

gw1500se disagrees
: MySQL extension are indeed deprecated whether the tutorial uses them or not. Reprogram it using PDO and then come back.