diff --git a/config.inc.php b/config.inc.php index b5efe503..ff10e9b4 100644 --- a/config.inc.php +++ b/config.inc.php @@ -755,6 +755,12 @@ function x_send_sms_clickatell($to, $message) { } */ +//MailLog2MySQL +//you need to install: https://github.com/bnchdan/MailLog2MySQL +$CONF["mail_log"]='NO'; + +$CONF['mailLog2MySQL_URL']="http://127.0.0.1:8888/api"; + // Theme Config $CONF['theme'] = 'default'; // Specify your own favicon, logo and CSS file diff --git a/configs/menu.conf b/configs/menu.conf index 1f0540d0..37fc61b8 100644 --- a/configs/menu.conf +++ b/configs/menu.conf @@ -29,6 +29,8 @@ url_totp_exceptions = totp-exceptions.php url_app_passwords = app-passwords.php # backup url_backup = backup.php +# maillog +url_maillog = maillog.php # viewlog url_viewlog = viewlog.php # logout diff --git a/public/maillog.php b/public/maillog.php new file mode 100644 index 00000000..56c99f2f --- /dev/null +++ b/public/maillog.php @@ -0,0 +1,128 @@ +getAll(); + $url = $CONF['mailLog2MySQL_URL']."?".explode("?", $_SERVER['REQUEST_URI'])[1]; + if (!isset($_GET["domain"]) && !authentication_has_role('global-admin')){ + $url.="&domain=".get_domains()[0]; + } + + $response = file_get_contents($url, false); + if ($response == NULL){ + die("Error from MailLog2MySQL!
Wrong \$CONF['mailLog2MySQL_URL'] set or MailLog2MySQL not installed "); + } + echo $response; + + die(); +} + + +function get_dovecot_logs(){ + if (validate_domain("domain") == 0 ){ + echo "Permission denied for domain ". $_GET["domain"]; + die(); + } + $CONF = Config::getInstance()->getAll(); + $url = $CONF['mailLog2MySQL_URL']."?".explode("?", $_SERVER['REQUEST_URI'])[1]; + + if (!isset($_GET["domain"]) && !authentication_has_role('global-admin')){ + $url.="&domain=".get_domains()[0]; + } + + $response = file_get_contents($url, false); + if ($response == NULL){ + die("Error from MailLog2MySQL!"); + } + + echo $response; + die(); +} + + +function get_postfix_logs(){ + if (validate_domain("mail_to_domain") == 0 && validate_domain("mail_from_domain") == 0 ){ + echo "Permission denied for domain ". $_GET["mail_to_domain"]; + die(); + } + $CONF = Config::getInstance()->getAll(); + $url = $CONF['mailLog2MySQL_URL']."?".explode("?", $_SERVER['REQUEST_URI'])[1]; + + if (!isset($_GET["mail_from_domain"]) && !isset($_GET["mail_to_domain"]) && !authentication_has_role('global-admin')){ + $url.="&mail_to_domain=".get_domains()[0]; + } + + $response = file_get_contents($url, false); + if ($response == NULL){ + die("Error from MailLog2MySQL!"); + } + + echo $response; + die(); +} + + + + + + + + +$smarty = PFASmarty::getInstance(); + +$smarty->assign('smarty_template', 'maillog'); +$smarty->display('index.tpl'); diff --git a/templates/maillog.tpl b/templates/maillog.tpl new file mode 100644 index 00000000..5c09e684 --- /dev/null +++ b/templates/maillog.tpl @@ -0,0 +1,326 @@ + +
+ + + + + + + + + +
+ +
+
+
+ + + + diff --git a/templates/menu.tpl b/templates/menu.tpl index 4f310202..6a5aadf3 100644 --- a/templates/menu.tpl +++ b/templates/menu.tpl @@ -219,6 +219,13 @@ {$PALANG.pAdminMenu_backup} {/if} + {* mail log *} + {if $CONF.mail_log==='YES'} +
  • + + Mail log
  • + {/if} {* viewlog *} {if $CONF.logging==='YES'}