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

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:

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");

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