Summary
I recently work on a case that involved slow incoming mail destined to SharePoint libraries. We found the problem was caused by a buildup of mail in the "drop" folders across multiple servers. Looking closer at the issue, we found that most of the messages were intended for aliases that no longer existed.
Example:
03/11/2019 12:19:09.61 OWSTIMER.EXE (0x2DB0) 0x2598 SharePoint Foundation E-Mail 6871 Information The Incoming E-Mail service has completed a batch. The elapsed time was 00:00:00. The service processed 3 message(s) in total. Errors occurred processing 3 message(s): Message ID: Message ID: Message ID: The following aliases were unknown: docs72 docs74 docs73 9dfbc79e-e62a-a083-7f7d-713af476a4e7
After the drop folder accumulates about 400 files, it prolongs the "job-email-delivery" timer job and can cause delivery delays.
What was done?
To resolve this issue, we provided a few scripts to keep the drop folder clean, by moving messages destined an unknown aliases to a holding folder and managed outside of the drop folder.
The first script uses a "search string" to match the unknown alias found the ULS events.
Example:
###################### #Move Mail based on name# ###################### $SrcDir = "c:\inetpub\mailroot\drop" $DestDir = "c:\inetpub\mailroot\badmail\spmail" if(!(Test-Path -Path c:\inetpub\mailroot\badmail\spmail)){ New-Item -ItemType directory -Path $DestDir} $SearchString = "To: <docs72@sp2016.com>" Get-Childitem $SrcDir -filter *.eml | ? {select-string $SearchString $_ -quiet} | move-item -Destination $DestDir
The 2nd script simply moved any message that was not processed after 10 minutes. So, after cleaning up all the known badmail, nothing should last longer than 10 minutes. If so, assume its bad and move it.
Example:
####################### #Move Mail after 10 minutes# ####################### $SrcDir = "c:\inetpub\mailroot\drop" $DestDir = "c:\inetpub\mailroot\badmail\spmail" if(!(Test-Path -Path c:\inetpub\mailroot\badmail\spmail)){ New-Item -ItemType directory -Path $DestDir} Foreach($file in (Get-ChildItem $SrcDir)) { If($file.LastWriteTime -lt (Get-Date).AddMinutes(+10)) {Move-Item -Path $file.fullname -Destination $DestDir} }
How does SharePoint handle it?
SharePoint does delete mail directly from the drop folder if it has not been processed after 24 hours via the OWSTIMER process and within the timer job.
Example:
As you can see from PROCMON , the OWSTIMER deletes the "eml" file directly from the DROP folder. However, since each bad mail will take 24 hours to be deleted, expect a large queue of messages in the drop folder on busy farms.
Conclusion
If you are in the process of a migration, chances are you will have e-mail destined to folders that no longer exist. Once a large build up of mail is created in the drop folder, expect delays. However, I hope this blog creates awareness and helps you manage the issue more efficiently, if you find yourself in this situation in the future.
Welcome to the SharePoint Blog! Learn best practices, news, and trends directly from the SharePoint team.