iono Documentation - E-Mail Templates

iono uses text file based templates to send out all e-mails. Replacement variables are used to add in information appropriate to each customer or e-mail. The iono_mailer class located in includes/libraries/iono/iono_mailer.php is used to handle all the e-mail needs for iono. It extends PHPMailer, a well known, open source mail sending class.

The class is made available by default during iono initialisation and can be accessed from the object $iono_mailer. It will not be in scope in any functions by default so you will need to use the global keyword to make it available.

Messages

Predefined messages are found in the templates/iono/mailer/ directory and look something like this, from user_invoice_due.tpl.php:

Hi $customer[first_name],

Invoice #$invoice[invoice_id] created on your account on $invoice[time_added] is now due. 
Please login at $global[system_url] to complete payment.

--
Regards,

$global[site_name]
$global[site_url]

Each replacement variable is formatted like a normal PHP variable and is an array. This variable is replaced before the message is sent with the appropriate value.

Predefined Messages

The default predefined messages are as follows. They are located in the templates/iono/mailer/ directory.

HTML is not supported in any e-mail template because it is often filtered, not displayed correctly or annoys the receipient.

Adding a new message

You can add your own predefined messages by calling the iono_mailer::add_message function from your code. This expects three parameters:

Sending

Sending a predefined message in an e-mail requires you to call the iono_mailer::send function. This function expects three parameters:

For example:

$iono_mailer->send('me@example.com', 'test', array('customer' => 1, 'license' => 1, 
'extra' => 1, 'invoice' => 1));

Raw messages

To send a raw message that does not have a predefined template you will need to use the iono_mailer::send_raw function. This function expects three parameters:

Replacement Variables

When defining a new message, you define which data is available in the form of an array containing either customer, license</code, <code>extra or invoice. When the message is parsed, this will make available an array of data which can then be replaced in the template with real values. This data is retrieved based on the ID you provide when calling the iono_mailer::send function. For example, to get details for customer #1 and license #2 you would call it like so:

$iono_mailer->send('me@example.com', 'test', array('customer' => 1, 'license' => 2));

The available data for each of these is as follows:

Customer

Accessed in the form $customer[varname].

When the user_reset message is used, the variable password becomes available with the new password generated by the system.

Extra

Accessed in the form $extra[varname].

License

Accessed in the form $license[varname].

Invoice

Accessed in the form $invoice[varname].

Global

In addition, the following variables are available globally in every template and are accessed in the form $global[varname].