Publish Date:31-08-2007
Archive Date:01-01-2020

mMail PHP Class

XmMail was created due to increasing frustration with the limitations of the built-in PHP mail() function, and the seemingly complex and obtuse installation and usage cases for other, popular-ish mail() function substitutes.

I guess what we were looking for was something that could send email in just a few lines of code, that was small, easy to use, supported some small features (like inline attachment zipping) with just a few parameter settings or two, and a good range of sending formats (text, html) with support for embedded graphics (like the email stationary in Outlook Express).

We also wanted to overcome the dependency on the mail() function's lack of SMTP AUTH and non-existent support for secure SMTP sessions (i.e. ssl and tls).

The end result is mMail which allows you to:

  • Direct sending without using sendmail or a local SMTP server
  • Support for ssl and tls SMTP sessions (tested with GMail, mDaemon)
  • Support for SMTP AUTH
  • Support for inline zip (just indicate you want the file zipped on attachment)
  • Support for text and html formatting
  • Support for embedded graphics a-la Outlook Express stationary
  • Really simple to use (see the sample files)


Installation of mMail is simple. Just include it:




In your PHP script and create as many instances of the mMail object as you need (you need to configure each one, of course).

Take a look at the included sample php scripts to get an idea how to use and configure the mMail object.


This PHP class has been tested extensively on PHP5.2.5, and should have no problems working with that and better.

Internally, the only external "requirements" are the PHP Tidy class ( and the PHP ZipArchive class ( In both cases, should the classes be unavailable mMail will switch to passthru mode, gracefully disabling the affected feature(s), put a warning in the error log and leave the affected data unprocessed (i.e. the mail should still get sent).

As the distributable version of the class is encoded and encrypted using the IonCube Encoder you will also need to add the IonCube Loader to your extensions by editing your php.ini file. You can get the instructions and download the necessary binaries here:


mMail is provided to the PHP community at large for no cost, but it did take time and effort to build and continues to take time and effort to enhance and fix. If you really find it useful or have really benefitted from using it, or you just want to show appreciation please donate USD5.00 to with a nice note on how it's helping you. It's a real vote of confidence and encouragement :).

Just click the shiny button below:

In any case, hope that you will enjoy this piece of software and that it helps you when you need it most!




Please send bug reports to: mmail at

Like mMail? Don't forget to check out our RealMail letter sending service too!

Like mMail? Don't forget to check out our FREE PDF sharing service too!

Listed at Hot Scripts in PHP