// September 13th, 2004 // No Comments » // Personal
Just a quicky as I am swamped at the moment but I recently ran into a problem with my “other” webhost and sending email via PHP.
For those in the know there is a built in PHP function called mail() which handles very basic emails. It has some serious limitations though – no html email, no attachments and the one that got me – no facility to authenticate against the SMTP server. Now my webhost doesn’t allow annonymous email to be sent and so Authentication is required.
Enter PHPMailer.
This is an open source, freely downloadble class* for PHP. It offers a host of features to the serious emailer including all of those I mentioned above and a lot more.
Nicer still is the method of installation. Ideally it would be stuck in the include_path defined in your php.ini file but you can also register the class on a per page basis. This is ideal if you don’t have control of the server. I simply added the following line to the global include (this is a PHP file that I require at the top of every page. It normally deals with database connections and session state):
ini_set("include_path", ".:/path/to/phpmailer/dir");
And that’s it. Fully fledged email capability from any PHP app and it takes seconds to install!
I love it when a plan comes together.
*Classes are low level, global extensions to a programing language