User Guide | Email Functions

The flexi auth library functions for sending and customising data within the libraries email template files.

Email Functions

Email Index | Email Config

Help with Function Parameters

Show / Hide Help

Name: The name of the function parameter (argument).

Data Type: The data type that is expected by the parameter.

  • bool : Requires a boolean value of 'TRUE' or 'FALSE'.
  • string : Requires a textual value.
  • int : Requires a numeric value. It does not matter whether the value is an integer, float, decimal etc.
  • array : Requires an array.

Required: Defines whether the parameter requires a value to be submitted.

Default: Defines the default parameter value that is used if no other value is submitted.

send_email()

Emails a user a predefined email template.


Library and Requirements

Available via the standard library.

Function Parameters
send_email(email_to, email_title, template, email_data) Help
Name Data Type Required Default Description
email_to string | array Yes FALSE Defines the email address to send the email to.
Multiple emails addresses can be defined either via an array or a comma delimited string.
email_title string No FALSE Defines the title of the email.
template string Yes FALSE Defines the filename of the email template used to send the email.
The email template directory is defined via the config. file.
email_data array Yes FALSE Defines the data that is to be displayed within the email.
The data defined here is made available as variables within the template file.
How it Works

The function uses the data within the 'email_data' argument to populate the email 'template' with data.

The template is then emailed to the defined email address(es).

Notes

The email settings can be defined via the config. file.

Return Values

Failure:FALSE

Success:TRUE

Examples
// Example #1 : Send an email to a single user.
$email_to = 'user@email.com';

// Example #2 : Send an email to multiple users.
$email_to = array('user_1@email.com', 'user_2@email.com');

$email_title = 'Example Email Title';
$template = 'example_email_template.php';
$email_data = array(
	'custom_var_1' => 'custom_value_1',
	'custom_var_2' => 'custom_value_2'
);

$this->flexi_auth->send_email($email_to, $email_title, $template, $email_data);

template_data()

flexi auth sends emails for a number of functions.
This function can set additional data variables that can then be included within these emails, by making them available to the email template files.


Library and Requirements

Available via the standard library.

Function Parameters
template_data(template, template_data) Help
Name Data Type Required Default Description
template string No FALSE Defines the email to use a different email template than the default.
template_data string | int | array No FALSE Defines additional data that is to be made available to the email template.
How it Works

The function updates a global array within the library that is checked just prior to an email being sent.

If the 'template' argument is defined, then the email function will use the new template file.

If the 'template_data' argument is defined, the data will be passed to the template file.
Provided the template file is updated to display this data, it will then be included when the email is sent.

Notes

This function must be called just prior to the library function that will send the actual email.

Return Values

Failure:FALSE

Success:TRUE

Examples
// Example #1 : Defining an alternative 'Forgotten Password' email template.
$template = 'altenative_forgotten_password.tpl.php';

// Call the template_data() function before the function sending the actual email.
$this->flexi_auth->template_data($template);

// Call the libraries forgotten_password() function.
$this->flexi_auth->forgotten_password(...);
// Example #2 : Defining additional data for the email template.
$template = 'altenative_forgotten_password.tpl.php';
$template_data = array(
	'custom_var_1' => 'custom_value_1',
	'custom_var_2' => 'custom_value_2'
);

$this->flexi_auth->template_data($template, $template_data);