IIS SMTP folders and domains explained

I created this post to explain the purpose of each SMTP folder. Understanding their various functions can assist in the troubleshooting process, if you encounter issues with mail delivery. There are numerous resources online that describe the SMTP folder structure however, I felt that they weren’t descriptive enough. So here’s my attempt at making this easier to understand.

SMTP Folders

When you install the SMTP service it creates the following default folder structure in order to process mail:

20140115161234

As you can see from the screenshot above, the folder C:\inetpub\mailroot\ contains 4 folders; Badmail, Drop, Pickup & Queue. They are explained below in the order that messages are processed:

Pickup

The SMTP service will process messages in the Pickup folder as outbound messages and will attempt to deliver them. To demonstrate what happens when a message is placed in the Pickup folder, perform the following:

1. Create a text file on your desktop called email.txt and paste the following into it, remembering to change the email address information to reflect your own details:

From: blog@yourdomain.com
To: email@yourdomain.com
Subject: Email test

This is the test body of the email

.

2. Save the changes to email.txt and then copy the file to C:\inetpub\mailroot\Pickup. The SMTP server monitors this folder and when it detects the email.txt file, it will read the contents and send the email to the address in the To: section. This should happen almost immediately.

3. Check the email address the email was sent to and it should arrive shortly – the email was sent to my Gmail account:

20130429184511

A quicker way and easier was of emulating the creation of messages in the Pickup folder is to run a PowerShell command that generates an email. Enter the command below, changing where appropriate the -To and -From addresses:

PS C:\Users\admin> Send-MailMessage -SMTPServer localhost -To xxxxx@gmail.com -From xxxxx@yourdomain.com -Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell"

Messages generally don’t build up in the Pickup folder, once detected the SMTP server will try to deliver them. If the intended recipient is a member of the local domain, the SMTP service will move the message to the Drop folder.

Drop

Incoming messages intended for the local domain are placed in the Drop folder. It is very unlikely that you will require the use of the Drop folder in a real-world scenario. Messages in the Drop folder must be retrieved using an email client such as Outlook but also require POP3 server software to be installed in order to enable end-users to connect to and retrieve those messages in the Drop folder. Server 2003 had the option to install the POP3 service but this has since been deprecated on versions of Windows Server since then.

If you are seeing that messages that your applications generate are building up in the Drop folder then this will be most likely be caused by configuring the default local domain to use your DNS domain namespace. The best way to illustrate this is to show you an example.

1. Currently my default local domain is configured with the name of my server, WEB1:

20140116125230

2. I use the PowerShell command below to send an email to blog@vsysad.com:

PS C:\Users\admin> Send-MailMessage -SMTPServer localhost -To blog@vsysad.com -From admin@vsysad.com -Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell"

The message is subsequently placed in the Pickup folder and processed and routed through to the mail server that handles mail for the vsysad.com domain. This message is delivered successfully.

3. However, lets change the default local domain to be vsysad.com per the below:
20140116115427

The vsysad.com DNS domain is now considered to be a local domain. If I were to use the same PowerShell command from step 2 above, the message will be processed per the usual method but will be placed the Drop folder:

20140116130612

The message will remain there until I use an email client to connect to the server via POP3 to download it. This will require 3rd party POP3 mail server software to enable this.

Queue

Messages that cannot be delivered  immediately are moved  from the Pickup folder to the Queue folder. The SMTP service will attempt repeatedly to deliver messages in the Queue folder. The number of times it will attempt to deliver the message is configured in the delivery tab, see below:

I have noticed that when delivering emails to domains such as Gmail and Yahoo for the first time, messages will remain in the Queue folder for some time while the SMTP server tries to re-deliver them.

Badmail

Emails that could not be delivered to the intended recipient are left in the Badmail folder. After the number of attempts configured in the Delivery tab (see screenshot above) to deliver the message have not been successful, the message will be moved to the Badmail folder. Messages in the Badmail folder will remain there until administrators diagnose the cause and implement a fix.

Common causes of messages ending up in the Badmail folder are incorrect or invalid email addresses and DNS issues. Follow instructions in these posts to verify DNS and successful mail routing respectively.

Once messages are in the Badmail folder, they can be opened up in notepad and examined. Open up the corresponding .BAD file(s) which will reveal the reason for the message delivery failure. An example is below, whereby the message failed because the recipient’s email address was invalid:

20140122005105

SMTP Domains

It is very important to clarify the distinction between a local domain and a remote domain within the SMTP settings. Choosing the wrong SMTP domain type will result in unintended results.

Local Domains

As stated in the Drop folder section above, a local domain is a DNS domain that is serviced by the local SMTP server. In my example, vsysad.com was the local default domain.

Messages that are received by an SMTP server that are destined for email addresses within the local domain will not be looked up in DNS, they will be dumped straight to the Drop folder. In the case of most environments the SMTP server is used simply to send mail and not to handle incoming mail for that domain. If this is the case for you, do NOT enable your DNS domain as a local domain within the SMTP server.

You can specify local domains as either default or alias. There can only be one default domain. An alias domain is an alias of the default domain. If you add a new domain and configure it as the new default, the previous default changes to an alias domain.

Remote Domains

Domains that are not designated as local are remote domains. The SMTP service looks up remote domains in DNS and will process the mail according to the settings configured for that specific remote domain. For example, you can add a remote domain and require that the SMTP service always use Transport Layer Security (TLS) encryption in sessions with that domain, which is the case for Gmail.

I hope this post demystifies the various SMTP folders and explains how mis-configuring the domain type can lead to unwanted messages in the Drop folder.

References:
SMTP Domains
How the SMTP Service works

  • Andy Emerine

    You said “I have noticed that when delivering emails to domains such as Gmail and Yahoo for the first time, messages will remain in the Queue folder for some time while the SMTP server tries to re-deliver them.” I followed the Setup and Configure SMTP Server on Windows Server 2008 R2 post and my messages are sitting in the Queue folder. I am sending to Gmail accounts. Is it possible something is configured incorrectly?

    • japinator

      Hi Andy, so try sending emails to other addresses such as your work email, do they go through?

  • Alex

    I did all what you instructed i also restart my server and yet the smtp didn’t work.. I configured this on windows 2008 rdp IIS 6 and it didn’t work.. i tested it with my real email address yet it sent to badmail so i guess the smtp if not working anymore on windows 2008 i believe the best is to buy smtp ip or domain from a relaible store cos all this confirguaration is not working anymore.. I tried it on AMS and use sever name as localhost then later i change it to 127.0.0.1 then later i changed it to my main vps IP all this method refuse to connect.. This tutorial didn’t help, dont know about others though?

    • japinator

      Hi Alex, the issue is not with the tutorial, the steps are bullet-proof and are used everyday with successful outcomes. That being said, what have you done to troubleshoot so far? Have you enabled logging? Have you confirmed DNS is working on your server using SMTPDiag? Have you used any command line tools to test email sending? If emails end up in the Badmail folder what are the reasons stated in the .BAD files for the failures? If you have a Gmail address follow the steps in this post to see if sending eail via Gmail works:

      http://wp.me/p2OBWC-nc

      Let me know the results. Be sure to provide useful information such as error info from logs and .BAD files in the Badmail folder if message sending fails.

      • Alex

        This is the error i got.. Unable to deliver this message because the follow error was encountered: “Error is processing file in pickup directory.”.

        The specific error code was 0xC00402CE.

        When i used on AMS it shows connecting failed Please here’s my YM id jahuh35 if you’ll be chance enough to come show me on team viewers cos i have tried all what you wrote as well.. Thanks for responding

  • Pingback: Setup and Configure SMTP Server on Windows Server 2008 R2 | vSYSAD()

  • Pingback: Setup and Configure SMTP Server on Windows Server 2012 | vSYSAD()

  • http://usahomesearch.com Craig Baker

    This was very very helpful in helping me understand why emails were going into the drop folder. Thanks so much. CB

    • http://www.vsysad.com japinator

      No problem Craig, glad it all worked out.

  • Pingback: Things to check when a CDO mail-enabled Classic ASP site is not sending mail after a migration to IIS7+ - Matt’s IIS Support Tidbits - Site Home - TechNet Blogs()