#native_company# #native_desc#
#native_cta#

Sending MIME Email With PHP Page 6

By Kartic Krishnamurthy
on August 7, 2000

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.

Conclusion

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:

<?php

$html_data =  '<htm1><body text="#OOOOdd" bgcolor="#000000"><hl>Hello</hl><body></html>';

$mime = new MIME_mail($to$from$subject);

$mime->attach($html_data,  ""OCTETBASE64INLINE);

$mime->send_mail ();

?>



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.
–Kartic

1
|
2
|
3
|
4
|
5
|
6