Troubleshooting IIS6 Virtual SMTP Server Auto-Start Failure After Windows Server 2008 R2 Reboot


2 views

After countless server reboots triggered by Windows Updates, I kept finding our IIS6 Virtual SMTP server in a stopped state. The service configuration showed "Automatic" startup type, yet it consistently failed to initialize post-reboot. This became particularly problematic as we host numerous client websites relying on this mail transport.

First, I examined the SMTP service dependencies using PowerShell:

Get-Service SMTPSVC | Select-Object -ExpandProperty DependentServices
Get-Service SMTPSVC | Select-Object -ExpandProperty ServicesDependedOn

The output revealed that SMTP depends on IIS Admin Service (IISADMIN) and RPC (Remote Procedure Call). Interestingly, the Event Log showed these services starting successfully before SMTP attempted initialization.

Modifying the service to use "Automatic (Delayed Start)" sometimes helps with dependency issues. Here's how to implement it via command line:

sc config SMTPSVC start= delayed-auto

While this improved the situation, it didn't completely resolve the problem - about 30% of reboots still left the service stopped.

Digging deeper into System Event Logs revealed error code 7023 with the message: "The Simple Mail Transfer Protocol (SMTP) service terminated with the following error: The system cannot find the file specified." This pointed to either missing files or registry corruption.

I developed this comprehensive repair script that handles multiple potential failure points:

# Stop dependent services
Stop-Service SMTPSVC -Force
Stop-Service IISADMIN -Force

# Re-register DLLs
regsvr32.exe /s %windir%\system32\inetsrv\ism.dll
regsvr32.exe /s %windir%\system32\inetsrv\iislog.dll

# Reinstall SMTP components
dism /online /enable-feature /featurename:SMTPServer /all
dism /online /enable-feature /featurename:SMTPServer-Web /all

# Reset service configuration
sc config SMTPSVC start= auto
sc config SMTPSVC depend= IISADMIN/RPCSS

# Clean and rebuild metabase
iisreset /stop
cd %windir%\system32\inetsrv
rename metabase.xml metabase.xml.old
iisreset /start

As a fail-safe, I implemented this PowerShell monitoring script that runs as a scheduled task every 5 minutes:

$smtpStatus = (Get-Service SMTPSVC).Status
if ($smtpStatus -ne "Running") {
    Start-Service SMTPSVC
    if ((Get-Service SMTPSVC).Status -ne "Running") {
        iisreset /restart
        Start-Service SMTPSVC
    }
    if ((Get-Service SMTPSVC).Status -eq "Running") {
        $body = "SMTP service was stopped and has been recovered at $(Get-Date)"
        Send-MailMessage -From "monitor@domain.com" -To "admin@domain.com" -Subject "SMTP Recovery Alert" -Body $body -SmtpServer "backup.smtp.server"
    }
}

After months of troubleshooting, this combination finally provided 100% reliability:

  • SMTP service set to Automatic (Delayed Start)
  • IIS Admin Service set to Automatic
  • Windows Process Activation Service set to Automatic
  • Regular metabase backups using %windir%\system32\inetsrv\backup
  • The monitoring script running as a scheduled task

After numerous Windows Server 2008 R2 reboots triggered by automatic updates, I noticed our virtual SMTP server consistently failed to restart automatically. While all other IIS6 components resumed normally, the SMTP service remained stubbornly offline until manually initiated, causing HTTP 500 errors across client websites.

First, I verified the SMTP service settings in Services.msc:


sc qc SMTPSVC
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: SMTPSVC
        TYPE               : 20  WIN32_SHARE_PROCESS 
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Windows\system32\svchost.exe -k iissvcs
        LOAD_ORDER_GROUP   : 
        TAG                : 0
        DISPLAY_NAME       : Simple Mail Transfer Protocol (SMTP)
        DEPENDENCIES       : IISADMIN
        SERVICE_START_NAME : LocalSystem

The issue stemmed from subtle timing problems in the service dependency chain. The SMTP service depends on IIS Admin Service (IISADMIN), which sometimes took longer to initialize than the system expected. Here's how I confirmed it:


# Create a service dependency report
sc enumdepend SMTPSVC 1024

I implemented two complementary solutions:

1. Delayed Auto-Start via Registry


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SMTPSVC]
"DelayedAutostart"=dword:00000001

2. Startup Script as Safety Net

Created a PowerShell watchdog script (SMTPWatchdog.ps1):


$service = Get-Service -Name SMTPSVC
if ($service.Status -ne 'Running') {
    Start-Service -Name SMTPSVC
    $smtp = New-Object Net.Mail.SmtpClient('localhost')
    $smtp.Send("admin@domain.com","admin@domain.com","SMTP Restarted",
        "SMTP service was restarted at $(Get-Date)")
}

Scheduled via Task Scheduler to run at system startup with 5-minute delay:


schtasks /create /tn "SMTP Monitor" /tr "powershell -file C:\scripts\SMTPWatchdog.ps1" 
/sc ONSTART /delay 0005:00 /ru SYSTEM

After implementation, I tested the solution through multiple controlled reboots. The combination of delayed auto-start and the watchdog script provided 100% SMTP service availability post-reboot. For additional monitoring, I added this to our Nagios configuration:


define service {
    use                  generic-service
    host_name            mail-server
    service_description  SMTP Service
    check_command        check_nt!SERVICESTATE!-d SHOWALL -l SMTPSVC
}