PHP Classes

Compose Mail: Sending e-mail in text and HTML with attachments

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 62%Total: 7,709 This week: 1All time: 231 This week: 560Down
Version License Categories
clssendmail 1.0.0GNU General Publi...Email
Description 

Author

This class is intended to send multipart e-mail messages.

It can send messages in HTML with an alternative text part to be viewed with e-mail programs that do not support displaying HTML messages.

Optionally, it can also send multiple files as attachments.

Picture of Daniel Andres Marjos
  Performance   Level  
Name: Daniel Andres Marjos is available for providing paid consulting. Contact Daniel Andres Marjos .
Classes: 13 packages by
Country: Argentina Argentina
Age: 53
All time rank: 261 in Argentina Argentina
Week rank: 411 Down3 in Argentina Argentina Down
Innovation award
Innovation award
Nominee: 2x

Details

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("another@email.com"); ) 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 require("$DOCUMENT_ROOT/library/clsSendMail.php"); // 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("somebody@somserver.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?" <itsme@thisserver.com> $mailer->sh_fromName("Hey hey!!! you know who am I, don't you?"); $mailer->sh_fromAddr("itsme@thisserver.com"); // 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 // want $mailer->addTextPlainBodyPart("Test message"); // Let's add the HTML content we created before $mailer->addHTMLBodyPart("$content"); // 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. $mailer->addAttachFromFile("$DOCUMENT_ROOT/library/clsSendMail.php","text/plain","attachment"); // We have just created our mail... Let's send it and enjoy echo $mailer->BuildAndSendMessage(); ?>

  Files folder image Files  
File Role Description
Plain text file clsSendmail.php Class the only file to this class. Includes a sample script
Accessible without login Plain text file README Doc. A brief explanation of the class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:7,709
This week:1
All time:231
This week:560Down
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:85%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:886