Tag Archives: Set-POPSettings

Enable POP3 and IMAP4 Logging

For testing purposes it can be useful to enable protocol logging on the POP3 and/or IMAP4 service. In Exchange 2010 this cannot be done using the Exchange Management Console or the Exchange Management Shell like you would do to enable protocol logging on the Send or Receive Connector but needs to be done using a config file.

There’s a Microsoft.Exchange.Pop3.exe.config or similarly a Microsoft.Exchange.Imap4.exe.config file located in the directory C:\Program Files\Microsoft\Exchange Server\ClientAccess\PopImap on the Exchange 2007/2010 Client Access Server.

When you open the file scroll down and locate the “ProtocolLog” key and set its value to “true”, like this:

<add key="ProtocolLog" value="true" />

When changed restart the POP3 or IMAP4 service in the Exchange Management Shell using the following command:

Restart-service MSExchangePop3
Restart-Service MSExchangeImap4

The log files can be found in the directory C:\Program Files\Microsoft\Exchange Server\Logging\Pop3

When you’re finished with troubleshooting don’t forget to disable protocol logging since it will consume a tremendous amount of disk space. Just to give you an idea, this is in the POP3 log file for only one session:


In Exchange 2013 it’s a bit different, you can use the Set-PopSettings cmdlet (and Set-ImapSettings cmdlet) to enable logging and set the directory where the log files are stored, for example:

Set-PopSettings -ProtocolLogEnabled $true -LogFileLocation "C:\Pop3Logging"

POP3 Server Unavailable. 21

Recently I entered the dreaded -ERR Server Unavailable. 21 error on an Exchange Server. The strange this was that this did not happen to all mailboxes but only to a couple of mailboxes. Nothing written in the eventlog, just –ERR Server Unavailable. 21 immediately after entering my credentials (this error can be seen when using TELNET to access a mailbox using POP3).

To get more information regarding the login process you can enable POP logging on the CAS Server. Be very careful with this and only enable it for test purposes. If you forget to turn it off most likely your CAS server will shutdown in a couple of days because the system drive is filled up with POP3 log files.

Enable POP logging using the Exchange Management Shell:

Set-POPSettings –ProtocolLogEnabled:$TRUE

And don’t forget to restart the POP3 service.

The POP3 log files are stored in C:\Program Files\Microsoft\Exchange Server\V14\Logging\Pop3. After testing and the Error Server Unavailable. 21 error show up, disable logging (Set-POPSettings –ProtocolLogEnabled:$FALSE), restart the service and open the POP3 log file.

2012-03-08T21:26:02.937Z,0000000000000002,1,, ,,0,23,5,user,joe@sixpack.com,R=ok;RpcL=-1;LdapL=-1
2012-03-08T21:26:13.296Z,0000000000000002,2,, ,,46,10,29,pass,*****,"R=""-ERR Server Unavailable. 21"";RpcL=-1;LdapL=-1;
Msg=User:joe:bf6c873e-4289-4a64-87bf-2ade894947cd:DAG04-MBX05:MBX19.E14.local; Excpt=""Could not load file or assembly ‘Microsoft.Exchange.Compliance, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.-FileNotFoundException"""

This turns out to be a bug in the Exchange 2010 setup (even in SP1) where the POP3 config file is not created appropriately. Unfortunately the same is true for IMAP4, but the fix is identical. The config files are called Microsoft.Exchange.Pop3.exe.config and Microsoft.Exchange.Imap4.exe.config and can be found in the directory C:\program files\Microsoft\Exchange Server\V14\ClientAccess\PopImap\

Add the following pieces to the XML file (both POP3 and IMAP4):

<assemblyIdentity name="Microsoft.Exchange.Compliance" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<codeBase version="" href="file:///C:\Program Files\Microsoft\Exchange Server\V14\bin\Microsoft.Exchange.Compliance.dll" />


Restart the POP3 and IMAP4 service and the POP3 Server Unavailable no longer appears.