Archive for Mailflow

Finding messages stuck in outboxes

Sometimes you encounter problems with the transport queues or with mailflow that are difficult to track down. Maybe your mail.queue file is ballooning in size even though you’ve replaced it with a fresh one. Maybe outbound mail isn’t going out as quickly as it used to.

One diagnostic in this situation is to determine whether any of the mailboxes have messages sitting in the Outbox. Sometimes large messages in the outbox can create loops if they are too large but you’ve removed all max-send-size limits. Sometimes the message in the Outbox is corrupted and is continually resubmitted to queuing.

The following script will look at all the mailboxes for messages in the Outbox and will compile a report of the mailboxes with items in their outboxes. Once you have the report, you can look at certain mailboxes with OWA and delete any problem items you find.

Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics | Where-Object {$_.Name -eq "Outbox" -and $_.ItemsInFolder -gt '0' } | Select-Object Identity, FolderType, ItemsinFolder, FolderSize | Export-CSV "C:\Outbox.csv"

Setting Anti-Spam and Junk Settings

If you are using the native Exchange 2013 anti-spam settings, you may also want to configure how the users are handling their junk mail and what the thresholds are for sending messages to their Junk folders. Since none of this is found in the GUI anymore, it’s helpful to know the PowerShell commands.

What I typically do when setting up a new Exchange 2013 server that is going to handle its own anti-spam settings is to first enable the anti-spam components. I do that by running the install-antispamagents.ps1 script in the Scripts directory from an escalated Exchange PowerShell prompt.

Once that’s done, I run the following to set the basic SpamConfidenceLevel to 8 and to reject messages for the ContentFiltering agent: Read more

Mail Disable Public Folders by Script

A customers sever turned out to have about 200 mail enabled public folders, where only a small handful needed to be mail enabled. The folders that needed to remain mail enabled were listed in the Switch statement, and all other folders were disabled by the script.

$PFList = Get-PublicFolder -Recurse

foreach($PF in $PFList) {

	$Folder = $PF.name

	$Process = Switch ($Folder)
	{
	 #"IPM_SUBTREE" { $False }
	 "* Admin Inbox" { $False }
	 "* Sales Inbox" { $False }
	 "* Info Inbox" { $False }
	 "* Returns Inbox" { $False }
	 Default { $True }
	}

    If ($Process -eq $True) {
        #write-host "Mail Disableing " $PF.Identity
        Disable-MailPublicFolder -Identity $PF.Identity -Confirm:$False
   }

}

Enable Exchange 2013 Spam Filtering

MX Logic or Postini:

If you use MX Logic, Postini, or a similar spam filtering service, you want to make sure you white list the IP ranges the service uses to submit email to your server.

Set-TransportConfig -InternalSMTPServers @{Add="208.65.144.0/21","208.81.64.0/21"}

These IP ranges are for MX Logic.

Enable RBL Checking and Sender ID Config:

If you are not using a 3rd party filtering service it is a good idea to enable RBL checking, and delete spoofed email as determined by SenderID.

Add-IPBlockListProvider -name bl.spamcop.net -lookupdomain bl.spamcop.net
Add-IPBlockListProvider -name zen.spamhaus.org -lookupdomain zen.spamhaus.org
Set-SenderIDConfig -SpoofedDomainAction Delete

Exchange 2013 Messsage Tracking “Console”

Exchange 2013 lacks the traditional Exchange Management Console that you are probably familiar with, and with it went the message tracking console that many administrators relied on to troubleshoot mail flow problems.  Sure there is now the Delivery Reports tool in the web Exchange Control Panel, but it’s just not quite the same, especially since it limits you to searching within a specific mailbox.

ECP Mail Flow

Luckily there is something similar to the Message Tracking Center in Powershell. Read more

Foward to DL fails

This one is not that big of a deal, and is a DUH on my part, but it may be something someone else runs into so I am going to post it.

Senario: User has a shared mailbox (SB1) that he wants to receieve email, and then foward it to his Personal mailbox (PM1) and an external user (EU1).

Solution: you need to setup a contact for EU1 that points to the users external email address. Setup a distribution group that contains the contact for EU1 as well and PM1. Then go into the mailbox settings and set it up so that the Delivery of email to SB1 is fowarded to the distribution group. That will make it so that if someone sends an email to SB1, it will go to SB1, PM1, and EU1.

Problem: But here is the problem. The forward worked correctly for internal emails, but did not work for external emails.   I had no idea that the little checkbox on the Distribution list that requires authentication works for forwards as well.  So if you want email from an outside address to foward correctly, you have to take off the check box for “Require that all senders are authenticated” on the distribution groups Message Delivery Restrictions settings.

To verify that this is the issue, you will want to check the message tracking logs and see if you can find one that shows the failure.  Then look for a “Recipient Status of 550 5.7.1 RESOLVER.REST.AuthRequired; authentication required”

To do this, I used the following command.

get-transportserver | get-messagetrackinglog -messagesubject "PUT SUBJECT HERE" -start 8/2/2012 -EventID Fail | FL | more

I always put a get-transportserver before any message tracking log commands.  We have several HUB servers, and this command will then search the traking logs for ALL of the HUB servers.

Note:  To make sure you don’t confuse the heck ot of your end users you will want to make the DL you created for the forward, as well as the Contact to the external user hidden from the address book.

I hope that is now clear as mud.  Comment if you have questions, or suggestions on how to do this.  I don’t like using rules in the actual mailbox because they are harder to maintain than the ability to use the EMC and powershell.

Script – Check Message Queue

note: following the transfer of this domain to the new owners, per user requests this article was recovered from the internet archive wayback machine, but may not be complete.

Here is a simple script I wrote that checks the message queue and then sends an email if the message queue goes over a specified limit. Read more