Tag Archives: POP3

POP3, IMAP4, Get-Service and Startup Type

When installing lots of Exchange servers, automation with PowerShell scripting can be very useful. This will ensure you get a consistent platform, and it reduces the chance of errors and misconfiguration.

For a customer I had to deploy 38 Exchange 2013 servers, and they were using POP3 and IMAP4 as well, so these services need to be installed on all Exchange 2013 servers.

By default, POP3 and IMAP4 are not running on an Exchange 2013 server, and the service Startup Type is set to Manual.

You can change the startup type to automatic using the Services MMC snap-in, but for 38 Exchange 2013 servers this isn’t funny anymore.

You can use the Get-Service cmdlet in Windows to retrieve information regarding Windows services, for example:

Get-Service –ServiceName MSExchangePOP3

Or add the Format-List option to get more detailed information:

image

You can use the –ComputerName option to retrieve similar information from another server:

image

There’s all kind of interesting information here, but the most important thing, the Startup Type information is missing here.

To retrieve the Startup Type information you can use the Get-WmiObjectcmdlet and filter on the service name, for example:

Get-WmiObject -Class Win32_Service -Property StartMode -Filter "Name='MSExchangePOP3'"

Please note the single and double quotes in the Filter option!

image

Again, you can use the –ComputerName option to retrieve this information from another server.

image

Note. On an Exchange 2013 (and Exchange 2016) server POP3 and IMAP4 are actually two services. There’s the CAS component (MSExchangePOP3) and the Mailbox server component (MSExchangePOP3BE). These services need to changed independently. The same is true for the IMAP4 service.

You can write a small script to create an overview of all Exchange servers with the Startup Type of all POP3 service, this will look something like:

$Servers = Get-ExchangeServer
ForEach ($Server in $Servers){
$Computer = $Server.Name
$Object = Get-WmiObject –Class Win32_Service –Property StartMode –Filter “Name=’MSExchangePOP3’”
Write-Host $Computer,$Object.StartMode
}

You can change the Startup Type of the POP3 service using the Set-Service command:

Set-Service –ServiceName MSExchangePOP3 –StartupType Automatic

And you can use the-ComputerName to change the Startup Type of a service running on another Server:

Set-Service –ServiceName MSExchangePOP3 –StartupType Automatic –ComputerName EXCH02

More information:

Use PowerShell to Find Non-Starting Automatic Services – https://blogs.technet.microsoft.com/heyscriptingguy/2012/12/18/use-powershell-to-find-non-starting-automatic-services/

Get-Service – https://technet.microsoft.com/en-us/library/hh849804.aspx

Set-Service – https://technet.microsoft.com/en-us/library/hh849849.aspx

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,127.0.0.1:110,127.0.0.1:24097 ,,0,23,5,user,joe@sixpack.com,R=ok;RpcL=-1;LdapL=-1
2012-03-08T21:26:13.296Z,0000000000000002,2,127.0.0.1:110,127.0.0.1:24097 ,,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=14.0.0.0, 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):

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

image

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

Telnet for POP3 and IMAP4

For testing purposes it is useful to know how to use TELNET to access a mailbox using the POP3 or the IMAP4 protocol. Suppose you have a mail server running with POP3 and IMAP4 enabled and you want to give it a try.

POP3

On a client open a command prompt and enter TELNET <<mailserver>> 110

If the server is running fine you’ll see a welcome message (like +OK The Microsoft Exchange POP3 service is ready) and you can enter the user credentials:

User <<username>>

Pass <<password>>

image

You are now successfully logged on. If you enter the LIST command all items in the Inbox are shown. RETR 1 will retrieve the first message in this list while DELE 1 will delete this first message. Bottom line is that you are successfully logged on, POP3 is running fine and the mailbox can be accessed.

Use the QUIT command to log off from the mailbox.

IMAP4

On a client computer open a command prompt and enter TELNET <<mailserver>> 143

If the server is running fine you’ll see a welcome message (like * OK The Microsoft Exchange IMAP4 service is ready) and you can enter the user credentials:

. login <<username>> <<password>>

That is: dot space login <<username>> <<password>>, you have to enter the dot and the space before the login command. If you omit either one the login will fail!

image

To get an overview of all the folders in the inbox you can use the LIST command:

. LIST “” “*”

Again, you have to enter the dot and the space before the actual LIST command.

Use the STATUS command to get the number of messages, for example:

. status inbox (messages)

image

Logoff from an IMAP4 session is a bit peculiar, use the CTRL + ] key combination, followed by the QUIT command (to actually quit the TELNET session).

image

Useful commands for a quick test of your mailbox and the POP3 and IMAP4 services.

If you want a complete overview of all commands please check this websites:

http://bobpeers.com/technical/telnet_imap and http://bobpeers.com/technical/telnet_pop