Index: /trunk/admin/include/functions_notification_by_mail.inc.php
===================================================================
--- /trunk/admin/include/functions_notification_by_mail.inc.php	(revision 25359)
+++ /trunk/admin/include/functions_notification_by_mail.inc.php	(revision 25360)
@@ -257,6 +257,5 @@
   if ($is_action_send)
   {
-    $nbm_user['theme'] = $user['theme'];
-    $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format'], $nbm_user['theme']);
+    $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']);
     $env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl');
   }
@@ -424,5 +423,5 @@
         set_user_on_env_nbm($nbm_user, true);
 
-        $subject = '['.$conf['gallery_title'].']: '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
+        $subject = '['.$conf['gallery_title'].'] '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
 
         // Assign current var for nbm mail
@@ -440,18 +439,20 @@
           )
         );
-
-        if (pwg_mail
-            (
-              format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
-              array
-              (
-                'from' => $env_nbm['send_as_mail_formated'],
-                'subject' => $subject,
-                'email_format' => $env_nbm['email_format'],
-                'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
-                'content_format' => $env_nbm['email_format'],
-                'theme' => $nbm_user['theme']
-              )
-            ))
+        
+        $ret = pwg_mail(
+          array(
+            'name' => stripslashes($nbm_user['username']),
+            'email' => $nbm_user['mail_address'],
+            ),
+          array(
+            'from' => $env_nbm['send_as_mail_formated'],
+            'subject' => $subject,
+            'email_format' => $env_nbm['email_format'],
+            'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
+            'content_format' => $env_nbm['email_format'],
+            )
+          );
+
+        if ($ret)
         {
           inc_mail_sent_success($nbm_user);
Index: /trunk/admin/notification_by_mail.php
===================================================================
--- /trunk/admin/notification_by_mail.php	(revision 25359)
+++ /trunk/admin/notification_by_mail.php	(revision 25360)
@@ -306,5 +306,5 @@
             if ($exist_data)
             {
-              $subject = '['.$conf['gallery_title'].']: '.l10n('New photos added');
+              $subject = '['.$conf['gallery_title'].'] '.l10n('New photos added');
 
               // Assign current var for nbm mail
@@ -378,18 +378,20 @@
                 )
               );
-
-              if (pwg_mail
-                  (
-                    format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
-                    array
-                    (
-                      'from' => $env_nbm['send_as_mail_formated'],
-                      'subject' => $subject,
-                      'email_format' => $env_nbm['email_format'],
-                      'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
-                      'content_format' => $env_nbm['email_format'],
-                      'theme' => $nbm_user['theme']
-                    )
-                  ))
+              
+              $ret = pwg_mail(
+                array(
+                  'name' => stripslashes($nbm_user['username']),
+                  'email' => $nbm_user['mail_address'],
+                  ),
+                array(
+                  'from' => $env_nbm['send_as_mail_formated'],
+                  'subject' => $subject,
+                  'email_format' => $env_nbm['email_format'],
+                  'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
+                  'content_format' => $env_nbm['email_format'],
+                  )
+                );
+
+              if ($ret)
               {
                 inc_mail_sent_success($nbm_user);
Index: /trunk/include/functions.inc.php
===================================================================
--- /trunk/include/functions.inc.php	(revision 25359)
+++ /trunk/include/functions.inc.php	(revision 25360)
@@ -1027,5 +1027,5 @@
  * @return string
  */
-function get_l10n_args($key, $args)
+function get_l10n_args($key, $args='')
 {
   if (is_array($args))
Index: /trunk/include/functions_comment.inc.php
===================================================================
--- /trunk/include/functions_comment.inc.php	(revision 25359)
+++ /trunk/include/functions_comment.inc.php	(revision 25360)
@@ -233,20 +233,20 @@
       $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comm['id'];
 
-      $content = array(
-        l10n('Author: %s', stripslashes($comm['author']) ),
-        l10n('Email: %s', stripslashes($comm['email']) ),
-        l10n('Comment: %s', stripslashes($comm['content']) ),
-        '',
-        l10n('Manage this user comment: %s', $comment_url),
+      $keyargs_content = array(
+        get_l10n_args('Author: %s', stripslashes($comm['author']) ),
+        get_l10n_args('Email: %s', stripslashes($comm['email']) ),
+        get_l10n_args('Comment: %s', stripslashes($comm['content']) ),
+        get_l10n_args(''),
+        get_l10n_args('Manage this user comment: %s', $comment_url),
       );
 
       if ('moderate' == $comment_action)
       {
-        $content[] = l10n('(!) This comment requires validation');
+        $keyargs_content[] = get_l10n_args('(!) This comment requires validation');
       }
 
       pwg_mail_notification_admins(
-        l10n('Comment by %s', stripslashes($comm['author']) ),
-        implode("\n", $content)
+        get_l10n_args('Comment by %s', stripslashes($comm['author']) ),
+        $keyargs_content
       );
     }
@@ -374,15 +374,15 @@
       $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id'];
 
-      $content = array(
-        l10n('Author: %s', stripslashes($GLOBALS['user']['username']) ),
-        l10n('Comment: %s', stripslashes($comment['content']) ),
-        '',
-        l10n('Manage this user comment: %s', $comment_url),
-        l10n('(!) This comment requires validation'),
+      $keyargs_content = array(
+        get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ),
+        get_l10n_args('Comment: %s', stripslashes($comment['content']) ),
+        get_l10n_args(''),
+        get_l10n_args('Manage this user comment: %s', $comment_url),
+        get_l10n_args('(!) This comment requires validation'),
       );
 
       pwg_mail_notification_admins(
-        l10n('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
-        implode("\n", $content)
+        get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
+        $keyargs_content
       );
     }
@@ -411,22 +411,22 @@
   include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
 
-  $content = array(
-    l10n('Author: %s', $comment['author']),
+  $keyargs_content = array(
+    get_l10n_args('Author: %s', $comment['author']),
     );
 
   if ($action=='delete')
   {
-    $content[] = l10n('This author removed the comment with id %d', $comment['comment_id']);
-  }
-  else
-  {
-    $content[] = l10n('This author modified following comment:');
-    $content[] = l10n('Comment: %s', $comment['content']);
+    $keyargs_content[] = get_l10n_args('This author removed the comment with id %d', $comment['comment_id']);
+  }
+  else
+  {
+    $keyargs_content[] = get_l10n_args('This author modified following comment:');
+    $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
   }
 
   pwg_mail_notification_admins(
-    l10n('Comment by %s', $comment['author']),
-		implode("\n", $content)
-		);
+    get_l10n_args('Comment by %s', $comment['author']),
+    $keyargs_content
+    );
 }
 
Index: /trunk/include/functions_mail.inc.php
===================================================================
--- /trunk/include/functions_mail.inc.php	(revision 25359)
+++ /trunk/include/functions_mail.inc.php	(revision 25360)
@@ -169,4 +169,14 @@
 
 /**
+ * Return string email format (text/html or text/plain)
+ * @param bool is_html
+ * @return string
+ */
+function get_str_email_format($is_html)
+{
+  return ($is_html ? 'text/html' : 'text/plain');
+}
+
+/**
  * Switch language to specified language
  * All entries are push on language stack
@@ -256,6 +266,6 @@
  * Send a notification email to all administrators
  * current user (if admin) is not notified
- * @param string $subject
- * @param string $content
+ * @param string|array $subject
+ * @param string|array $content
  * @param boolean $send_technical_details - send user IP and browser
  * @return boolean
@@ -267,24 +277,31 @@
     return false;
   }
-  
-  // for backward compatibility < 2.6
-  if (is_array($subject))
-  {
-    $subject = l10n_args($subject);
-  }
-  if (is_array($content))
-  {
-    $content = l10n_args($content);
-  }
 
   global $conf, $user;
-  
+
+  if (is_array($subject) or is_array($content))
+  {
+    switch_lang_to(get_default_language());
+
+    if (is_array($subject))
+    {
+      $subject = l10n_args($subject);
+    }
+    if (is_array($content))
+    {
+      $content = l10n_args($content);
+    }
+
+    switch_lang_back();
+  }
+
   $tpl_vars = array();
   if ($send_technical_details)
   {
-    $tpl_vars['TECHNICAL'] = 
-      l10n('Connected user: %s', stripslashes($user['username'])) ."\n".
-      l10n('IP: %s', $_SERVER['REMOTE_ADDR']) . "\n" .
-      l10n('Browser: %s', $_SERVER['HTTP_USER_AGENT']);
+    $tpl_vars['TECHNICAL'] = array(
+      'username' => stripslashes($user['username']),
+      'ip' => $_SERVER['REMOTE_ADDR'],
+      'user_agent' => $_SERVER['HTTP_USER_AGENT'],
+      );
   }
 
Index: /trunk/include/functions_user.inc.php
===================================================================
--- /trunk/include/functions_user.inc.php	(revision 25359)
+++ /trunk/include/functions_user.inc.php	(revision 25360)
@@ -230,14 +230,14 @@
       $admin_url = get_absolute_root_url().'admin.php?page=user_list&username='.$login;
 
-      $content = array(
-        l10n('User: %s', stripslashes($login) ),
-        l10n('Email: %s', $_POST['mail_address']),
-        '',
-        l10n('Admin: %s', $admin_url),
+      $keyargs_content = array(
+        get_l10n_args('User: %s', stripslashes($login) ),
+        get_l10n_args('Email: %s', $_POST['mail_address']),
+        get_l10n_args(''),
+        get_l10n_args('Admin: %s', $admin_url),
         );
 
       pwg_mail_notification_admins(
-        l10n('Registration of %s', stripslashes($login) ),
-        implode("\n", $content)
+        get_l10n_args('Registration of %s', stripslashes($login) ),
+        $keyargs_content
         );
     }
Index: /trunk/themes/default/template/mail/text/html/notification_admin.tpl
===================================================================
--- /trunk/themes/default/template/mail/text/html/notification_admin.tpl	(revision 25359)
+++ /trunk/themes/default/template/mail/text/html/notification_admin.tpl	(revision 25360)
@@ -3,5 +3,7 @@
 {if isset($TECHNICAL)}
 <p style="padding-top:10px;font-size:11px;">
-{$TECHNICAL|nl2br}
+{'Connected user: %s'|translate:$TECHNICAL.username}<br>
+{'IP: %s'|translate:$TECHNICAL.ip}<br>
+{'Browser: %s'|translate:$TECHNICAL.user_agent}
 </p>
 {/if}
Index: /trunk/themes/default/template/mail/text/html/notification_by_mail.tpl
===================================================================
--- /trunk/themes/default/template/mail/text/html/notification_by_mail.tpl	(revision 25359)
+++ /trunk/themes/default/template/mail/text/html/notification_by_mail.tpl	(revision 25360)
@@ -39,11 +39,11 @@
 <p>{'See you soon,'|@translate}</p>
 <p style="text-align:center">{$SEND_AS_NAME}</p>
+<hr>
 <p>
-<br><hr>
 {'To unsubscribe'|@translate}{', click on'|@translate} <a href="{$UNSUBSCRIBE_LINK}">{$UNSUBSCRIBE_LINK}</a><br>
 {'To subscribe'|@translate}{', click on'|@translate} <a href="{$SUBSCRIBE_LINK}">{$SUBSCRIBE_LINK}</a><br>
 {'If you encounter problems or have any question, please send a message to'|@translate} <a href="mailto:{$CONTACT_EMAIL}?subject={'[NBM] Problems or questions'|@translate}">{$CONTACT_EMAIL}</a><br>
-<hr><br>
 </p>
+<hr>
 {if not empty($recent_posts)}
 </div>
Index: /trunk/themes/default/template/mail/text/plain/notification_admin.tpl
===================================================================
--- /trunk/themes/default/template/mail/text/plain/notification_admin.tpl	(revision 25359)
+++ /trunk/themes/default/template/mail/text/plain/notification_admin.tpl	(revision 25360)
@@ -3,4 +3,6 @@
 {if isset($TECHNICAL)}
 -----------------------------
-{$TECHNICAL}
+{'Connected user: %s'|translate:$TECHNICAL.username}
+{'IP: %s'|translate:$TECHNICAL.ip}
+{'Browser: %s'|translate:$TECHNICAL.user_agent}
 {/if}
Index: /trunk/tools/triggers_list.php
===================================================================
--- /trunk/tools/triggers_list.php	(revision 25359)
+++ /trunk/tools/triggers_list.php	(revision 25360)
@@ -569,10 +569,4 @@
 ),
 array(
-  'name' => 'mail_group_assign_vars',
-  'type' => 'trigger_event',
-  'vars' => array('array', 'assign_vars'),
-  'files' => array('include\functions_mail.inc.php (pwg_mail_group)'),
-),
-array(
   'name' => 'nbm_event_handler_added',
   'type' => 'trigger_action',
@@ -707,31 +701,13 @@
 ),
 array(
-  'name' => 'send_mail',
-  'type' => 'trigger_event',
-  'vars' => array('bool', 'result', 'string', 'mail_to', 'string', 'mail_subject', 'string', 'mail_content', 'array', 'mail_headers'),
+  'name' => 'before_send_mail',
+  'type' => 'trigger_event',
+  'vars' => array('bool', 'result', 'mixed', 'to', 'array', 'arguments', 'PHPMailer', 'mail'),
   'files' => array('include\functions_mail.inc.php (pwg_mail)'),
 ),
 array(
-  'name' => 'send_mail_content',
-  'type' => 'trigger_event',
-  'vars' => array('string', 'content'),
-  'files' => array('include\functions_mail.inc.php (pwg_mail)'),
-),
-array(
-  'name' => 'send_mail_headers',
-  'type' => 'trigger_event',
-  'vars' => array('array', 'headers'),
-  'files' => array('include\functions_mail.inc.php (pwg_mail)'),
-),
-array(
-  'name' => 'send_mail_subject',
-  'type' => 'trigger_event',
-  'vars' => array('string', 'cvt_subject'),
-  'files' => array('include\functions_mail.inc.php (pwg_mail)'),
-),
-array(
-  'name' => 'send_mail_to',
-  'type' => 'trigger_event',
-  'vars' => array('string', 'to'),
+  'name' => 'before_parse_mail_template',
+  'type' => 'trigger_action',
+  'vars' => array('string', 'cache_key', 'string', 'content_type'),
   'files' => array('include\functions_mail.inc.php (pwg_mail)'),
 ),
