Tortuga Software - web development (programming) with PHP / MySQL / Apache
Useful PHP-classes, scripts, manuals, articles, tutorials
E-mail: info@usefulclasses.com ICQ: 749345 GTalk: varenich@gmail.com
Let Visitors Enjoy Your Site!
   

  Save To del.icio.us Digg this Post Save To Slashdot Bookmarks Save To FURL Save To Newsvine Save to Yahoo! My Web 2.0 Save To Reddit Save To Simpy Save To Shadows

E-mail Message Text Generation Class


PHP classes library, that allows you to change e-mail message text and template engines easily, makes scripts code readable, with easy to change logic.

Very often it is necessary to send electronic message from PHP-scripts, for example after a new user registered in the system. Usually message sending is built in right into the registration script.

Example:

<?php
// User registration here
// ...

// Now sending a message to User

// Create E-mail message text right here
$letterTxt = “
Dear $userName,

You have successfully registered in our system.

Please use following login and password to enter our system:

Login: $userLogin
Password: $userPassword

With best regards,
Administration”;

// Sending letter
// ...
?>

Aforesaid variant of sending message is totally unreadable, when the letter text is of a big size (which happens very often) and contains formatting and a lot of variables. Saying nothing that to translate the text you will have to change the script which inevitably will cause mistakes. To transfer the letter into HTML becomes absolutely an unsolvable task.

To make a work easier for programmer and separate letter text from source codes template engines are used (they also have advanced possibilities for processing of variables). Then you must create an object of the template engine, indicate the name of the template is, and set variables:

Example:

<?php
// User registration here
// ...

// Now sending a message to User

// 1.Including template engine library
require_once("smarty/Smarty.class.php");

// 2.Creating instance of template object
$tpl = new Smarty;

// 3.Assigning variables to the letter’s text
$tpl->assign('userName',$userName);
$tpl->assign('userLogin',$userLogin);
$tpl->assign('userPassword',$userPassword);

// 4.Generating letter’s text
$letterTxt = $tpl->fetch('letter.tpl');
If (PEAR::isError($letterTxt)) die ($letterTxt->getMessage());

// Sending letter
// ...
?>
In case you need to change a template engine (for example to replace Smarty template engine with Fast Template), set of variables, the name of a file containing text of the letter, you have to change source code of the program (as for aforesaid example you have to change all four points).

The same code but using Fast Template:

<?php
// User registration here
// ...

// Now sending a message to User

// 1.Including template engine library
require_once("class.FastTemplate.php3");

// 2.Creating instance of template object
$tpl = new FastTemplate("/path/to/templates");

// 3.Assigning variables to the letter’s text
$tpl->assign($_REQUEST);

// 4.Generating letter’s text
$tpl->parse(MAIN, "letter");
$letterTxt = $tpl->fetch("MAIN");

// Sending letter
// ...
?>

So you need a programmer for that, for whom it will take a lot of time (as to change libraries is much harder that merely to change the letter text).

Mym library of PHP-classes allows not only to remove the text of a letter from the programming code, but also a template engine and the process of setting variables for the text of the letter as well.

Registration script will look like that:

<?php
// User registration here
// ...

// Now sending a message to User

// 1.Including mym library
require_once("mym/mym_Letter.php");

// 2.Creating instance of letter object
$tpl = mym_Letter::factory($conf[‘tplEngine’],$conf[$conf[‘tplEngine’]][‘tplConf’]);
If (PEAR::isError($tpl)) die ($tpl->getMessage());

// 3.Generating letter’s text
$letterTxt = $tpl->generateText($conf[‘tplName’],$_REQUEST);
If (PEAR::isError($letterTxt)) die ($letterTxt->getMessage());

// Sending message
// ...
?>

Now, in case you will have to replace template engine (Smarty with Fast Template), YOU WON’T NEED TO CHANGE A TEXT OF THE LETTER AT ALL! You just have to change the name of the template engine in the configuration array (hash). This way you can achieve full independence of programming code from text letter generation.

Library features and benefits

  • Totally documented methods and properties of classes make handling of the library easier and more transparent
  • The library was created on the basis of design patterns—recommendations of the programmers’ international community of solving standard project-oriented tasks—which guarantees high quality and flexibility of the programming code.
  • Proper exception/errors handling—each method of the library processes exceptions properly and in critical cases returns the object of the error indicating the exact place of the bug—minimizes the time spent on finding a mistake and will reduce ineffective time losses.
  • Installation instruction: detailed instruction of library installation allows spending much less time for setting up.
  • For easier understanding of working principles installation instruction contains UML-diagrams as illustrations.
  • Detailed examples of usage for fast and simple start.
  • Developer’s instructions: to create your own modules easily there is an instruction how to do it. Update the library according your system requirements spending minimum of time!
  • Additional consulting on installation: in case you have decided to write your own module for the library and met a mistake you can not understand our experts would be pleased to help you for a tiny reward. You will save a lot of time and nerves giving a task for those who understand it perfectly.
  • Life time guarantee: all mistakes emerging while using library will be corrected for free during all time of usage. There is only one condition: our code must not be modified.
  • Changing of template engine, the template itself and its configuration parameters is carried out by mere changing of one parameter of configuration, which extremely facilitates and speeds up complex procedure of script logic modification.
  • Easy realization of such possibilities like translating into other languages and changing of a letter format. Just analyze the script language and insert letter template from the appropriate directory.
  • You can use the library not only for text letter generation, but for any other needs, for example for displaying web pages. All advantages of removing text from the initial script can be perfectly used for the whole of your site!
Requirements:
  • PHP 4.x, 5.x
This library which facilitates programmer’s work to a great extent and contains detailed instructions costs only $7.

How to buy

We accept payments via Share-It.com and Moneybookers.com systems by using credit cards, checks and inner payments

What you will get:

  • Initial code of the library
  • Documentation in the phpDoc format.
  • Installation instruction
  • Instruction manual
  • Instructions how to create your own modules
Payment procedure:
  1. Choose payment system (Share-It or Moneybookers).
  2. Follow the payment instructions of the system you chose.
  3. On the confirmation payment page you will acquire unique user name/order number and the password for downloading of the library.
The cost of the library is $7

[ORDER]

In case you have any questions before or after buying the library please send them to info@usefulclasses.com

Be in touch with Script Updates

Subscribe to:

Tortuga Software News and Updates | RSS
Name:
Email:
Format:

 

Useful PHP scripts   Home

   Log In


Our PHP-it! Blog

Interesting PHP Articles

Interesting PHP Resources

 



 
Do You Have a Question? We'll Be Glad to Answer You
Your name: Message text:  
E-mail:
 
 
 
 
Contacts
E-mail: info@usefulclasses.com
ICQ: 749345
GTalk: varenich@gmail.com
  Creative Commons License

Text of this work is licensed under a Creative Commons Attribution-NoDerivs 2.5 License.
To use this work, please specify a hyperlink to this site: http://www.usefulclasses.com

Import Export Trade Leads Portal. Submit for Free.

Time are important to you. In free criminal records addition, you have to keep in. . Informative reviews lookness.com: what types of memory do notebook computers typically use. . business card templates free Crestline . kasko Viļāņos