I recently encountered an issue with email alerts in Team Foundation Server 2012. Unfortunately the process to enable email logging is a little more in-depth than it should be and I’ll cover that process here.

1. First open a command prompt on the TFS application server and navigate to the “tools” directory under your TFS install directory. Then run the following command:

tfsconfig configuremail /Enabled:True

2. Open PowerShell on the TFS application server and run the following commands to increase the log level from 0 to 2:

# Load client OM assembly.
[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
 
$collectionBaseUrl = "http://YOURTFSSERVER:8080/tfs/YOURCOLLECTION/";
 
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($collectionBaseUrl);
$collectionHive = $tfs.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry]);
 
# Set the setting in the collection hive.
$collectionHive.SetValue("/Service/Integration/Settings/NotificationJobLogLevel", "2");

3. Login to the SQL server and run the following query against the TFS_Configuration database:

SELECT TOP 10 DATEADD(HOUR, -7, StartTime) AS StartTimePDT, RESULT, ResultMessage
 
FROM [Tfs_Configuration].[dbo].[tbl_JobHistory]
 
WHERE JobId = 'A4804DCF-4BB6-4109-B61C-E59C2E8A9FF7' AND RESULT <> 0
 
ORDER BY StartTime DESC

4. You will now see a detailed error under the “ResultMessage” column. In my case the following part of the error pointed me in the right direction:

Exception: System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender

5. To clear this specific issue I needed to allow SMTP relay on our Exchange server for the TFS application servers IP. Generally this isn’t needed when sending to internal addresses but I think the way TFS was pulling the email addresses from AD had something to do with it.

6. After you are done troubleshooting remember to set the logging level to 0 in PowerShell:

# Set the setting in the collection hive.
$collectionHive.SetValue("/Service/Integration/Settings/NotificationJobLogLevel", "0");

Leave a Reply