This class has been written to use along with PHPMailer and the Smarty Template Engine.


Installation is as easy as include this file into the php file that you would like to use it from.

You will need to have the Smarty template engine setup/installed with a configuration file in the /configs folder (or as specified by smarty's installation) and the required phpMailer class.



//innitiate Smarty
$smarty = new Smarty();

//Load the config file from the /configs folder used with Smarty

//Send to email, from email, from who and the email subject
$to = 'recipientEmail@domain.tld';
$from = 'sendersEmail@domain.tld';
$fromName = 'Senders Name';
$subject = 'This is the subject of the email that will be sent';

//Variables to be used in the smarty template for the body of the email
$vars = array();
$vars['name'] = 'Ron Darby';
$vars['website'] = '';

//Template to use from within the /templates folder used with the smarty template engine.
$tpl = 'email_body_content.tpl';
//To attach any attachments to the email, you must define the location of the file, in this case from the site root
$logo = 'images/logo.jpg';

$mail = new smartyEmail($smarty,$tpl,$vars,$to,$from,$fromName,$subject);


echo 'Mail sent successfully';

Contacting Ron

I'm available to help at anytime by emailing me using the email adress provided in the source codes, I work as a freelance web developer with a portfolio available on and at SaffaPost Web Development