activeMailLib Manual v0.1
What is activeMailLib? |
activeMailLib is a PHP class to validate and send MIME E-mail messages using the PHP function mail(). |
What can activeMailLib actually do? |
activeMailLib can generate MIME TEXT or HTML E-mail messages with user defined headers, body parts and character encoding. File parts (attachments) can be included in the generated messages too. It is also capable of doing E-mail address validation based on a regular expression and optionally on the PHP function getmxrr() (UNIX systems). |
activeMailLib methods overview |
|
activeMailLib E-mail validation regular expression |
^[_a-zA-Z0-9-](\.{0,1}[_a-zA-Z0-9-])*@([a-zA-Z0-9-]{2,}\.){0,}[a-zA-Z0-9-]{3,}(\.[a-zA-Z]{2,4}){1,2}$ |
activeMailLib code examples | |
SIMPLE TEXT E-MAIL | SIMPLE HTML E-MAIL WITH MANY RECIPIENT |
<?php require_once("activeMailLib.php"); $email = new activeMailLib(); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To("you@yourhost.com");//set a valid E-mail $email->Subject("activeMailLib Text Mail"); $email->Message("This is an test for the activeMailLib"); $email->Send(); ?> |
<?php require_once("activeMailLib.php"); $to=array("you@yourhost.com","info@yourhost.com")//set valid E-mails $email = new activeMailLib("html"); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To($to); $email->Subject("activeMailLib HTML Mail"); $email->Message("This is an test for the <b>activeMailLib</b>"); $email->Send(); ?> |
SIMPLE TEXT E-MAIL WITH VALIDATION (MANUALLY) | SIMPLE HTML E-MAIL WITH VALIDATION (AUTOMATICALLY) |
<?php require_once("activeMailLib.php"); $to="you@@yourhost..com";//invalid E-mail $email = new activeMailLib(); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To($to); $email->Subject("activeMailLib Text Mail"); $email->Message("This is an test for the activeMailLib"); if ($email->checkAddress($to)) $email->Send(); else print "Invalid E-mail: ".$to; ?> |
<?php require_once("activeMailLib.php"); $to="you@@yourhost..com";//invalid E-mail $email = new activeMailLib("html"); $email->enableAddressValidation(); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To($to); $email->Subject("activeMailLib HTML Mail"); $email->Message("This is an test for the <b>activeMailLib</b>"); $email->Send(); //this E-mail was not sent. If you want to be sure: if ($email->isSent($to)) print "E-mail sent: ".$to; else print "Invalid E-mail: ".$to; ?> |
SIMPLE TEXT E-MAIL WITH SERVER FILE ATTACHMENTS | SIMPLE HTML E-MAIL WITH AN UPLOADED FILE ATTACHMENT |
<?php require_once("activeMailLib.php"); $att1="files/somefile1.txt";//set a valid file path $att2="files/somefile2.txt";//set a valid file path $email = new activeMailLib(); $email->enableAddressValidation(); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To("you@yourhost.com");//set a valid E-mail $email->Subject("activeMailLib Text Mail"); $email->Message("This is an test for the activeMailLib"); $email->Attachment($att1,"somename1.txt"); $email->Attachment($att2,"somename2.txt"); $email->Send(); ?> |
<?php require_once("activeMailLib.php"); $email = new activeMailLib("html"); $email->enableAddressValidation(); $email->From("webmaster@yourhost.com");//set a valid E-mail $email->To("you@yourhost.com");//set a valid E-mail $email->Subject("activeMailLib HTML Mail"); $email->Message("This is an test for the <b>activeMailLib</b>"); if (isset($_FILES['att'])){ $email->Attachment($_FILES['att']['tmp_name'],$_FILES['att']['name']); } $email->Send(); ?> |
(c) Giorgos Tsiledakis, Crete Greece |