• Recent Articles

  • Script for SMTP Queue Monitoring (updated for version 11.2)

    This simple PHP script which you can run on a custom schedule from System - Tools - Tasks & Events will monitor the SMTP Temp (no subfolders), SMTP Outgoing (no subfolders) and the SMTP Retry queues (recursive including subfolders). If the number of messages in queue exceeds the preset threshold, it sends an email and/or text message to a defined number.

    The configuration is within config.ini with self-explanatory parameters, including server ID allowing to distinguish multiple installations, custom message content, and paths to where the queues are located. The parameter notify_always=true means a notification will be sent each time the queue is checked on the configured schedule, and can be disabled after initial setup. The number of items reported is counted from all *.imap or *.tmp files within the queue folders (and subfolders in case of SMTP Retry) and can be customized in the script.

    The files should be extracted and placed in a folder within \IceWarp\html, eg. \IceWarp\html\monitoring\.

    Click here for FAQ with detailed instructions.

    We have used it to detect a number of spam relays already!

    Special thanks to Dayan, IceWarp Asia Pacific.

    Updated 04/20/2015:

    - supports version 11.2 and higher priority queues
    - shows progress when called from browser
    - shows errors when the script generates an error
    - there is NO change to the config.ini so if upgrading from 11.1.x to 11.2.x simply replace the queuemonitor.php file

    queuemonitor_v11.1.zip
    queuemonitor_v11.2.zip
    Comments 12 Comments
    1. ardy's Avatar
      I have implemented this but I am not sure if it is doing anything, How would I test it........any guidence
    1. dayandj's Avatar
      Hi Ardy,

      To test the script set the either or both notify_always to true and then manually trigger the script. With notify_always set to true you should receive a queue report even if the threshold is not reached.
    1. dayandj's Avatar
      Quote Originally Posted by ardy View Post
      I have implemented this but I am not sure if it is doing anything, How would I test it........any guidence
      Hi again Ardy,

      For a detailed explanation on how to setup and test the script please take a look at this kb article; http://support.icewarp.com.au/index....eue-monitoring
    1. ardy's Avatar
      Thanks A bunch..... The instruction table is great I will try this Wowww this is grate.......
    1. dayandj's Avatar
      Hi Ardy,

      You are very welcome. BR, Dayan
    1. ardy's Avatar
      Hello BR,
      First off I want to thank you for your detailed instructions I think it is very much so helpful and it answered bunch of questions for me.....it is a keeper. I still am not able to get it to work....... I am not sure what the problem is, but am trying different things to see if it makes it click...... so here a bit of info on my server.......
      • it is windows server 32bit
      • I am running the latest released version of IceWarp

      Some info as to what I did......
      The php.ini
      • I noticed the IceWarp installation has a PHP directory which tells me you use your own installed version. I also noticed and PHP directory in my root C:\ seem to be an earlier installation, so the question is which PHP.exe the Icewarp is using.....Just to be safe I modify both *.ini files......
      • I have entered my own e-mail into this as sendmail_from =
      • I also noticed that the Root (X:\) PHP.ini has a parameter for the port which is 25, The IceWarp (X:\Program Files\IceWarp\php) PHP doesn't have this parameter
      The Config.ini
      • on both mail_from and to_mail i have placed my own e-mail address
      • Notify_Always is True and the thresholds are low numbers
      • my smtp_temp path X:/Mail_data/temp/SMTP/
      • my smtp_outgoing path X:/Mail_data/_outgoing/
      • my smtp_retry path X:/Mail_data/_outgoing/_outgoing/retry/
      Task and events are configured as suggested......
      • The executable is pointing to X:\Program Files\IceWarp\php\php.exe
      • Type is Executable
      • Parameter is pointing to X:\Program Files\IceWarp\html\monitoring\queuemonitor.php
      ================================================== ========
      I have been monitoring the smtp log files and I don't see any indication of any mail related to this at all, I keep monitoring but I don't think it is running........or the parameter part in the Task/event is not passing
      One Thought I had is that win 32 os some times depending on the program doesn't like spaces in the path i.e X:\Program Files\IceWarp\php\php.exe should be "X:\Program Files\IceWarp\php\php.exe" basically getting encapsulated in ""...

      I don't know but I haven't gave up, I will try to figure this out because the tool is a must have with all the junk and attacks........

      I still want to thank you it seem to be a great tool, can't wait to get it working, I think IceWarp should incorporate this into their tool section,.......

      Regards
      ardy
    1. dayandj's Avatar
      Hi Ardy,

      Sounds like you have everything setup correctly. I would suggest turning on PHP display_errors so we can see if the script is generating any errors.

      In your php.ini file look for display_errors, change this to display_errors=on . Save the file and restart your IceWarp Control service.

      Now trigger the script by calling it from you web browser for example http://mail.yourdomain.com/monitor/queuemonitoring.php and see if any errors are displayed. Also check your Console > Status > Logs > PHP Errors for any errors thrown by the script.

      If there is an error generated then let me know and we should be able to determine what the problem is and fix it.

      BR,

      Dayan
    1. ardy's Avatar
      Hello BR:

      Currently I am running on port 32000, i.e WWW.domain:32000/webmail. I have tested the php under iis and it works fine...... I just can't figure out how to run this under IceWarp\php. I think the problem is php under Icewarp. only if I could make it run phpinfo.php under icewarp then I know it works and I can troubleshoot more , but as of now I am stumped........

      I was able to get it running creating a virtual directory in IIs pointing to html/monitoring/queuemonitor.php got bunch of error

      Warning: syntax error, unexpected '=' in C:\Program Files\IceWarp\html\monitoring\config.ini on line 24 in C:\Program Files\IceWarp\html\monitoring\queuemonitor.php on line 11 Notice: Use of undefined constant SMTP_TEMP - assumed 'SMTP_TEMP' in C:\Program Files\IceWarp\html\monitoring\queuemonitor.php on line 57 Notice: Use of undefined constant path - assumed 'path' in C:\Program Files\IceWarp\html\monitoring\queuemonitor.php on line 57 Fatal error: Uncaught exception 'RuntimeException' with message 'Directory name must not be empty.' in C:\Program Files\IceWarp\html\monitoring\queuemonitor.php:28 Stack trace: #0 C:\Program Files\IceWarp\html\monitoring\queuemonitor.php(28) : DirectoryIterator->__construct('') #1 C:\Program Files\IceWarp\html\monitoring\queuemonitor.php(57) : rsearch(NULL, '/\.imap$|\.tmp$...', false) #2 {main} thrown in C:\Program Files\IceWarp\html\monitoring\queuemonitor.php on line 28
      I don't know man,,,I am guessing the problem is PHP under IceWarp server.....I hope to figure it out because I want this tool so bad........I will figure it out.....any guidance is appreciated....
    1. ardy's Avatar
      BR:
      I have been working on this trying to troubleshoot this, here is the latest...... the last test I did, from Tools| Task and events I manually ran the script via Run Now and the system gave me the following error now this is the windows message.......

      php.exe - Unable to locate components
      This application has failed to start because php_mbstring.dll was not found. Re-installing the application may fix this problem
      The task is pointing to ....
      Executable: "C:\Program Files\IceWarp\php\php.exe"
      Type: Executable
      Parameters: "..\html\monitoring\queuemonitor.php"

      I have checked under C:\Program Files\IceWarp\php\ext and php_mbstring.dll is there....

      I was wondering what if I for Executable point to c:\php\php.exe and see what happens, I think I will try this.......

      Any Thoughts.....?
    1. dayandj's Avatar
      Hi Ardy,

      in your C:\Program Files\IceWarp\php\php.ini file look for extension=php_mbstring.dll and make sure there is no ; in front if it. The semi colon means the ext is disabled.

      Also could you post your queue monitor config.ini file contents here for me to review as it appears to be generating errors.
    1. ardy's Avatar
      There is no ; at the end...... or beginning.....I am attaching both php.ini which is under IceWarp installed directory.(i.e C:\Program Files\IceWarp\PHP) and the queue monitor config.ini. I had to zip it up the upload program keep giving me error if I kept the original files as they were....

      Thanks for your help
      Ardy
    1. dayandj's Avatar
      Hi Ardy,

      There were no files. If you are having trouble attaching a file in the forum maybe you can open a ticket in support@icewarp.com.au and we will take it from there.
  • Recent Article Comments Widget

    hsw

    Hi, i've made a script for import of vcard files,
    all vcard files are saved as username.txt

    //... Go to last post

    Script to import data into vCards

    hsw on 08-13-2016