logo-radria.gif
   
Blog Download Documentation Forum Tasks Home
Blog Download Documentation Forum Tasks Home
barside-right.gif
barside-left.gif
logo-sql.gif





This documentation is for the old version of the mailing tools. The new version is documented at: mailing_tools2

RADRIA has an amazing mailing tool by means of which user can store the templates with the database and can send the email while required using these templates.

The mailing tools comes in the RADRIA package and after downloading that package we will have a table in the data base by name emailtemplate

This table is for adding our own custom templates.

The class that executes the functionality is called Emailer.class.php

Now let us take an example by means of which we will send login details to the users which are created from the administration side.

Let us assume that the table where the user details are kept as candidate and we have the fields

etc.

Now we have an event link after clicking the event link the system should send and email using the email template.

Now we will have our custom template in the emailtemplate table as follows:

idemailtemplate»> 4

subject »> Login Details

bodytext »>[firstname],

          Here is your username and password.
           username:[username] 
           password: [passwd] 

bodyhtml »>

sendername »> logindetails

senderemail »> support@sqlfusion.com

thumbnail »>

internal »>

       

Please refer to the emailtemplate table.

Now in the event code we will see how we are going to send the email.

First we will retrieve the email_address from the candidate table, this is the email id to which the email will be send.

Let us store the email id to $email_to_send

The next step we will fetch the username and passwd from the candidate table and will send the email.

The code will look like this:

 
        $conx = $this->getDbCon();
        $email = new Emailer() ;
	$qGet = new sqlQuery($conx) ;
  	$qGet->query("select * from `candidate` where `id`='$id'");// $id= candidate id for which data to be retrieve
	if ($qGet->getNumRows() > 0) {
		while($data = $qGet->fetchArray()) {
			$email->loadEmailer($conx, 'logindetails') ;
			$email->mSubject = $email->stringFusion($email->mSubject, $data) ;
      			$email->mBody = $email->stringFusion($email->mBody, $data) ;
			 if (strlen($email->mBodyHtml) > 5) {
      				$email->mBodyHtml = $email->stringFusion($email->mBodyHtml, $data) ;
      				$email->sendMailHtml($email_to_send) ;
      			} else {
	   			$email->sendMailStandard($email_to_send) ;
      			}
		}
         }

Here we are loading the template in

 $email->loadEmailer($conx, 'logindetails') ;

logindetails is the template name.

Now we will get the email subject from the emailtemplate table as

$email->mSubject = $email->stringFusion($email->mSubject, $data) ;

Here $data is an array that contains the data retrieved from the query and will do all the replace task inside [].

Next it will create the body data as

$email->mBody = $email->stringFusion($email->mBody, $data) ;

We have the body in the databse as:

bodytext »>[firstname],

          Here is your username and password.
           username:[username] 
           password: [passwd] 

This will be parsed and [firstname] will be replaced by the firstname in candidate table.

[username] will be replaced by username in candidate table.

and [passwd] will be replaced by passwd in candidate table.

Thats all we are now ready to use Email Template Tool in RADRIA

 
library/mailing_tools.txt · Last modified: 2009/03/27 16:58 by admin
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki