Skip to main content

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.

Logging setttings

Enable logging consumes a lot of disk space if our mail server is busy all day, but it surely helps us find out what really happened.


Powershell script scanning awstats log file to remove email addresses that no longer exist


# Default hmailserver's log folder
$Dir="C:\Program Files (x86)\hMailServer\Logs"

# Email pattern
$regex = '\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b'
$today = (Get-Date).ToString("yyyy-MM-dd")

# Scan hmailserver's awstats log file for 550 return code
Select-String -Pattern '\tSMTP\t\?\t550\t0$' $Dir\hmailserver_awstats.log  | Out-File $Dir\hmailserver_awstats-$today.txt -width 200 -Append


if($?) {
select-string -Path $Dir\hmailserver_awstats-$today.txt -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $Dir\hmailserver_awstats-$today-filtered.txt
}



# Remove duplicate lines
if($?) {
Get-Content $Dir\hmailserver_awstats-$today-filtered.log.txt | sort | Get-Unique > $Dir\hmailserver_awstats-$today-unique.txt
}
# End of script

Popular posts from this blog

IIS: Delete cached files on server running IIS

Delete cached files on server running IIS When changing css, javascript files, check to delete if IIS still caches old files in the default folder C:\inetpub\temp\IIS Temporary Compressed Files\<sitename>\$^_gzip_D^\ Apply to: IIS 8.5

Linux command: du - disk usage

Where have all my storage gone? du summarize disk usage of the set of FILEs, recursively for directories.

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'