Online demo Privacy policy

Custom authentication

Piler allows you to alter or fix the authentication, eg. add extra email addresses, etc. You may think about it as a post authentication hook.

The following example adds a 2nd domain name to your email addresses. Let's say you have two addresses, and, and you want to read emails for, and Then add the following to config-site.php:

$config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'my_custom_func';

function my_custom_func($username = '') {
   $session = Registry::get('session');
   $data = $session->get("auth_data");

   $a = array();

   foreach($data['emails'] as $email) {
      $s = explode("@", $email);
      array_push($a, $s[0] . "");

   $data['emails'] = array_merge($data['emails'] , $a);

   $session->set("auth_data", $data);

If you want to change some aspects of the gui before the authentication takes place, then write a similar function. The following example would allow logins from a certain domain only, and reject others:


function iii($username = '') {
   global $session;

   if(!strstr($username, "")) {
      $session->set("auth_data", array());

Piler also supports a pre authentication hook which runs before any authentication is performed.

Look at the below example. You define only IMAP_PORT and IMAP_SSL in config-site.php, and set the IMAP_SERVER based on the domain part of the username:

$config['CUSTOM_PRE_AUTH_FUNCTION'] = 'my_imap';

function my_imap($username = '') {
   global $session;

   if(strstr($username, "")) {
      define('IMAP_SERVER', '');
   } else if(strstr($username, "")) {
      define('IMAP_SERVER', '');
   } else {
      define('IMAP_SERVER', '');
Google Analytics Alternative