PHP Classes

cPHPezMail: Send text and HTML email messages with attachments

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2005-12-11 (9 years ago) RSS 2.0 feedStarStarStarStar 66%Total: 2,108 All time: 1,781 This week: 1,138Up
Version Licenses Categories  
cphpezmail 1.0Artistic License, B...Email
Description Author  

This class can be used to compose and send e-mail messages.

The messages may be in plain text or HTML or both.

The messages may also include one or more attachment files from the server file system or being uploaded to the server via Web forms. The class can recognize the MIME type from the file name extension.

The headers for the subject, sender, recipients, character set, encoding and other headers may be configured.

Picture of Charin Nawaritloha
Name: Charin Nawaritloha <contact>
Classes: 1 package by
Country: Thailand Thailand
Age: ???
All time rank: 13453 in Thailand Thailand
Week rank: 1623 Down3 in Thailand Thailand Equal

cPHPezMail Version 1.2

This Script Developed under GNU GENERAL PUBLIC LICENSE, please see GNU-English.txt


- Object Base Script, EASY to use with your PHP script.
- Support Plain Text, HTML and Plain Text + HTML format
- Support multiple reciepients To:, Cc: and Bcc:
- Support E-mail address with Screen Name format.
- Support attach POST file (Upload from your html form - $_FILES).
- Support attach Local file (Files in your webhost or harddisk).
- Auto-detected MIME file type.
- Export your E-mail to .eml format (this format support in e-mail clients like MS-Outlook).


1. Open file "inc_cPHPezMail.php" in text editor and modifies values in function cPHPezMail() then save changes.
2. Copy file "inc_cPHPezMail.php" to your webhost.
3. Create directory match $sTempFileName and change mode to 777 (in Unix host) to store upload file (because most webhost run PHP in Safe Mode so you can't open file outside the specified directory)
4. In your script please include file "inc_cPHPezMail.php" and create a new object with $cYourVal = new cPHPezMail();


You can edit cPHPezMail configulation, go to function cPHPezMail() and edit this value...

//MIME Boundary
$this->sMimeBoundary = '==Multipart_Boundary_X'. md5(time()) .'X';
$this->sAltBoundary = '==Alternative_Boundary_X'. md5(time()) .'X';

//Charset and Encoding Bit for Plain Text and HTML
$this->sCharset = 'iso-8859-1';
$this->nEncoding = 7;

//target directory+filename to copy uploaded files.
$this->sTempFileName = './upload_temp/' . md5(time()) . '.tmp';

//if your mime type of attach file does not match in list, it use this value
$this->sDefaultMimeType = 'application/octet-stream';

//add or modify your mine type here.
$this->aMimeType = array(...);

//and after line 199, if you want to make default value TO DO here
$this->AddHeader('MIME-Version', '1.0');
$this->AddBcc('', 'My FullName');

Prevent editing method-source-code-area , use OOP - extends instead.


[in your html form]
<form action="yourPHPscript.php" method="POST" enctype="multipart/form-data">
  <input type="file" name="fileX">

[in your PHP script]
$cMail = new cPHPezMail();

//Don't try to add invalid e-mail address format
$cMail->SetFrom('', 'Your Name');

$cMail->AddTo('', 'Peter Norton');
$cMail->AddTo('', 'Bill Gate');

$cMail->AddCc('', 'Screen Name is optional');
$cMail->AddCc('', 'Mishell Mable');

$cMail->AddBcc('', 'Perter Hotmail');

$cMail->SetSubject('This is subject - cPHPezMail Testing...');

$cMail->SetBodyText('This is Text format mail mail.');
$cMail->SetBodyHTML('<HTML>This is HTML format <br>Test Test <b>Body Body</b> mail mail</HTML>');


//Attach POST file

//Attach local file
$cMail->AddAttachLocalFile('./index.php', 'text/plain');
$cMail->AddAttachLocalFile('./makejs.php', 'MIME type is optional');

//if you want to export as eml format do this...
$sEMLData = $cMail->ExportEML();

//send your e-mail

How to support my script:
- Please Votes & Reviews this script.
- Send comments to me.
- Send E-Card to me.

Version 1.2 Release 2005-09-09
	- fixed incorrect attach local file(s) [thank you Wouter from Holland, reported this bug]

Version 1.1 Release 2005-07-14
	- fixed can't attach file(s) when send only plain text e-mail.

Version 1.0 Release 2004-04-12
	- first release
  Files folder image Files  
File Role Description
Accessible without login HTML file GNU-ThaiTranslation.html Lic. GNU-Thai Translation
Plain text file inc_cPHPezMail.php Class cPHPezMail
Accessible without login Plain text file readme_en.txt Doc. Document

 Version Control Unique User Downloads Download Rankings  
 0%Total:2,108All time:1,781
 This week:0This week:1,138Up
User Ratings User Comments (1)  
 All time
6 years ago (kishore kumar)