Mail performance monitor

Intro

I have build this tool to monitor email performance. You can monitor on a regular basis how long it takes to deliver mail from one account to another. The solution consists of 2 parts, a webpage and a Send/Receive command line utility. The webpage is used to view the results, and the command line utility is used to send and receive mail from configured mailboxes on a regular basis.

If you would like to use this solution, please keep in mind that this tool:

  • supports SMTP and POP3 for sending and receiving. No IMAP!
  • does not have a friendly user interface (yet) for configuration or installation.
  • does run in a CMD box (not a windows service(yet))
  • with improper configuration can get you on spam list(s)
  • only works with a MySQL database server
  • requires IIS and .net 4.0

I build this in a hurry a while ago, so the solution may not be perfect, but it works for me. If you have any comments or suggestions, please let me know via the contact form or the comments. You can get the source code on request, if you would like to improve the solution.

Installation

The first step is to extract the files. Place the files to any location you wish. In the folder Console you can find the CMD utility, in the folder Web the webpage files. The second step to get this tool running is to create a database. The zip file includes 2 SQL files:

  • ExampleDB.sql: This is the complete database including a sample configuration.
  • CleanDB.sql: This is the complete empty database.

Import the SQL file of your choice, create a MySQL user, and give this full user permission to the database. Finally, update the connection string in the config files for the Webpage and CMD utility (MailPerformanceMonitorConsole.exe.config and web.config). At this point, both the CMD Utility and Webpage should be working. If you used ExampleDB.sql it will probably generate errors because of non-existing mail accounts. And if you used CleanDB.sql nothing will happen.

Configuration

Futher configuration can be done in 3 places: app.conf, web.config and in the database. In MailPerformanceMonitorConsole.exe.config which belongs to the CMD utility there are 2 settings (in the node appSettings):

  • DeleteOldMessages: Indicates if the CMD utility should clean-up the messages table. If this is set to true, also look at the DeletedMessagesOlderThan setting.
  • DeletedMessagesOlderThan: If the previous setting is set to true, it will delete messages older than this number of days.

In the web.config which belongs to the webpage there is 1 settings (in the node appSettings):

  • MaxThreshold: With this setting you can determine the maximum time it should take to deliver a e-mail. If a e-mail takes longer than this number of seconds to deliver, it becomes an exception (marked red on the webpage).

In the database you have to insert records in 2 tables, tblmailbox_mbx and tblsendschema_ssa. First we take a look at tblmailbox_mbx. In this table you can add mail accounts to send mail to and receive mail from. I will describe the fields below:

  • mbxId: Unique ID, auto increment.
  • mbxDescription: Description for own reference, isn’t used anywhere.
  • mbxSMTPUsername: Username for the SMTP server of your e-mail account. NULL if no authentication is required.
  • mbxSMTPPort: TCP port for your SMTP server.
  • mbxSendInterval: How often should mail be sent from this account? Value in seconds, minimum value is 30. Don’t set this value to low, if you send a lot of mail your mail server could be listed on a spamlist
  • mbxReceiveInterval: How often should mail be received for this account? Value is in seconds, minimum value is 30.
  • mbxPOPUsername: Username for the POP3 server of your e-mail account.
  • mbxPOPPassword: Password for the POP3 server of your e-mail account.
  • mbxPOPHostname: Server address for the POP3 server of your e-mail account.
  • mbxPOPPort: TCP port for the POP3 server of your e-mail account.
  • mbxSMTPPassword: Password for the SMTP server of your e-mail account. NULL if no authentication is required.
  • mbxSMTPHostname: Server address for the SMTP server of your e-mail account.
  • mbxEmailAddress: Primary mail address of your e-mail account.
  • mbxPOPSSL: Does your POP3 server use SSL? 1 for yes, 0 for no.
  • mbxSMTPSSL: Does your SMTP server use SSL? 1 for yes, 0 for no.
  • mbxActive: Is mail account active? If this is set to false, no mail will be sent or received for this mailbox.

Create at least 2 rows for different e-mail accounts. Sending mail from and to the same account isn’t very useful unless you are using a different SMTP server (like for instance, the SMTP server of your ISP). Remember the mbxId’s generated when inserting rows and to which e-mail account they belong. You will need them in the next table. The next table where we will insert a few rows is tblsendschema_ssa. This table defines from and to which e-mail accounts mail should be sent. If for instance you created two e-mail account rows in the first table with mbxId’s 1 and 2, and you want to send mail back and forth between these accounts, you have to create 2 rows in this table. One that indicates mail should be send from mbxId 1 to 2, and one to send from mbxId 2 to 1. Below you can find an explanation of the fields:

  • ssaId: Unique ID, auto increment.
  • ssaFrommbxId: The mailbox Id to send mail from, it will use the SMTP info from this mailbox record to send mail.
  • ssaTombxId: The mailbox Id to receive mail to, it will user the POP info from this mailbox record to check incoming mail.
  •  ssaActiveFrom: not used (yet)
  • ssaActiveTo: not used (yet)
  • ssaActive: Is the schedule active? Note: if the from or to mailbox is not active, this record will not be used and treated as inactive
Start and usage

If you have created the schedules you can start the CMD utility and watch it go. After a while you can look at the Results.aspx page to look at the results. You can click on the exceptions link to view only the results which exceeds the threshold. If the Receive time is empty and Time taken is zero, it means the mail never got delivered.

preview

Sources and Downloads

Leave a Reply