The ComposeMail class was born to accomplish a very particular requirement
I had. I needed to send an email in both formats: text/plain and
text/html. I've looked around in the repository and I was about to use
Manuel Lemos' own Email sending class, but it was too complex for what I
wanted to do, so I wrote this simple class. I know it lacks of the CC and
BCC capabilities, but I will add those features as soon as I can. Here is
a brief explanation on how the class works, via this simple script:
Even though the code was added to the class a long time ago, I didn't updated
this doc properly, so here we go...
++ Added 2004-12-11 ++
The class has now support for CarbonCopy (CC), BlindCarbonCopy (BCC), ReturnPath, EnvelopeTo
via sh_<<Header>> (i.e. sh_CarbonCopy("firstname.lastname@example.org"); )
A new method was added: BuildAndSendMessageTextPlain, which sends the mail without any attachment
and without HTML part. Just the text/plain section.
// First of all, we include the class file. I assume there is no need to document this
// We build the HTML part of our mail. In this case, a simple bold sentence
$content="<b> this is a test</b>";
// Let's create an instance of our class. We must specify here who will
// receive the mail and the subject.
$mailer=new ComposeMail("email@example.com","test mail");
// Let's specify who we are
// This two functions will make the "From: " header looks like:
// From: "Hey hey!!! you know who am I, don't you?" <firstname.lastname@example.org>
$mailer->sh_fromName("Hey hey!!! you know who am I, don't you?");
// Let's add a sample plain text as the body. Notice that plain text is
// not required to be the same as HTML w/o tags. It could be anything you
// Let's add the HTML content we created before
// Let's add our class file as an attachment. Take a look at the parameters
// First, we specify the full path of the file to attach
// In second place, we say the method to give the file the specified mime
// type. It uses the same mime types that you can get when handling
// uploaded files in PHP. In this case, text/plain, but it could be
// image/jpeg, image/gif or anything that fits the actual file type.
// In third place, we must say it will be attached, and not shown inline.
// We have just created our mail... Let's send it and enjoy