Two other methods that are worth mentioning are print_mail() and send_mail(), both taking the $force argument. print_mail() prints the entire email message and send_mail() sends the message using the PHP mail() function. Optionally, send_mail() uses an SMTP object and it's send method (both user specified) to send the email.
Creating MIME compliant messages is not as complicated as it first appears to be and can be implemented in a rather simple fashion. MIME messages can give a real facelift to many web site features.
The class we developed above covers core ideas and it can be extended in ways limited only by one's imagination. For instance, one can write a "detach()" function to remove an attachment given the slot number of an attachment (attach() method returns this information).
This class MIME_mail can be used to send HTML-based email without much alteration but embedded images can not be sent; this is a topic that needs special attention.
However, HTML without images or with images referenced using absolute URLs or <BASE> tags can be sent even using class MIME_mail. As an example:
The recipient of this email will get an email with a black background and the text "Hello" written in blue!
Sending complete inline HTML messages, along with some other advanced topics in MIME-compliant emailing, deserve special consideration, which, hopefully, will be addressed in a continuation of this article.
The class, constants file and working examples can be downloaded as a zip archive.