PHP Classes
elePHPant
Icontem

cPHPezMail: Send text and HTML email messages with attachments

Recommend this page to a friend!
  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 (10 years ago) RSS 2.0 feedStarStarStarStar 66%Total: 2,120 This week: 1All time: 1,802 This week: 1,047Up
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

Details
cPHPezMail Version 1.2
COPYRIGHT 2004-2005 CHARIN NAWARITLOHA.
Contact: inews@charinnawaritloha.net


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




Feature:

- 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).



Installation:

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();


Configuration:

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('myself@myemail.com', 'My FullName');


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





Example:

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


[in your PHP script]
<?php
require_once('inc_cPHPezMail.php');
$cMail = new cPHPezMail();

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

$cMail->AddTo('xxxx-x@xxxthai.com', 'Peter Norton');
$cMail->AddTo('yyyy1234@yybo.co.th', 'Bill Gate');

$cMail->AddCc('some_one@oneway123.com', 'Screen Name is optional');
$cMail->AddCc('some_two@oneway123.com');
$cMail->AddCc('some_three@oneway123.com', 'Mishell Mable');

$cMail->AddBcc('some_one@hotmail.com', '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>');

$cMail->SetCharset('TIS-620');
$cMail->SetEncodingBit(8);

//Attach POST file
if(isset($_FILES['fileX']))
{
	$cMail->AddAttachPOSTFile($_FILES['fileX']);
}

//Attach local file
$cMail->AddAttachLocalFile('./index.php', 'text/plain');
$cMail->AddAttachLocalFile('./header.js');
$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
$cMail->Send();
?>





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


HISTORY:
--------
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,120
This week:1
All time:1,802
This week:1,047Up
User Ratings User Comments (1)
 All time
Utility:96%StarStarStarStarStar
Consistency:96%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:554
 
Excellent
7 years ago (kishore kumar)
70%StarStarStarStar