How to send email alerts from TFS through Gmail.
After I have set-up the Team Foundation Server I needed to set-up the email alerts, especially alerts for when new work items get assigned. We are using Google apps in the company, so I just set-up another account inside our Google domain for alerts and went to configure the TFS. For me, this turned out to be the most challenging part of the Team Foundation Server set-up.
This blog entry helped me a lot:
To send email alerts through Gmail you will need to install the following components:
Visual Studio Team System Web Access 2008 Power Tool
And you will also need to set-up an SMTP virtual server on the machine.
Setting-up TFS:
After installing the web access power tool go to
C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\Services\Web.config
And set it to look like this:
xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="ConnectionString" value="Application Name=TeamFoundation;Persist Security Info=False;Initial Catalog=TfsIntegration;Data Source=SERVERNAME\TEAMSTUDIO;Integrated Security=SSPI"/>
<add key="eventingEnabled" value="true" />
<add key="DetailedExceptions" value="true" />
<add key="emailNotificationFromAddress" value="TFS@YourGmailDomain.com" />
<add key="smtpServer" value="localhost" />
appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\Plugins;bin\Plugins\zh-chs;bin\Plugins\zh-cht;bin\Plugins\de;bin\Plugins\es;bin\Plugins\fr;bin\Plugins\it;bin\Plugins\ja;bin\Plugins\ko"/>
assemblyBinding>
runtime>
<httpHandlers>
<add verb="*" path="methodology.asmx" type="Microsoft.TeamFoundation.Client.MethodologyDownloadHandler" />
<add verb="*" path="methodologyUpload.asmx" type="Microsoft.TeamFoundation.Client.MethodologyUploadHandler" />
httpHandlers>
system.web>
The actual SMTP configuration is found at:
C:\Program Files\Microsoft Visual Studio 2008 Team System Web Access\Web\web.config
You need to set it up to look something like this:
(the file is long, so I will only include the parts you need to edit)
<emailSettings sendingEmailEnabled="true" />
<system.net>
<mailSettings>
<smtp deliveryMethod="network" from=" TFS@YourGmailDomain.com ">
<network host="localhost" port="25" enableSsl="false" defaultCredentials="true"/>
smtp>
mailSettings>
system.net>
This will make TFS to connect to an SMTP server on localhost, now you need to set-up the virtual SMTP server.
Setting-up the SMTP server:
Go to ISS manager ->
Default SMTP Virtual Server -> Properties -> Delivery -> Outbound Security
And choose “Basic authentication”
Username: TFS@ YourGmailDomain.com
Password: YourPassword
Do not enable TLS encryption
Then go to
Default SMTP Virtual Server -> Properties -> Delivery -> Advanced
Fully-qualified domain name:
ServerName.LocalDomainName.local
Smart host:
[localhost]
Then under Default SMTP Virtual Server -> Domains add a new remote domain
“*.com”
In its properties set:
Enable “Allow incoming mail to be relayed to this domain”
Forward all mail to smart host
[127.0.0.1]
Outbound Security
Choose “Basic authentication”
Username: TFS@ YourGmailDomain.com
Password: YourPassword
Do not enable TLS encryption
As you have noticed the SMTP server is still set to localhost, this is where Stunnel comes in to connect you to the Gmail server.
Set-up Stunnel
You need to set-up Stunnel as a windows service (described in http://www.stunnel.org/faq/run.html#ToC7)
The stunnel.conf file should look something like this:
; Sample stunnel configuration file by Michal Trojnara 2002-2006
; Some options used here may not be adequate for your particular configuration
; Certificate/key is needed in server mode and optional in client mode
; The default certificate is provided only for testing and should not
; be used in a production environment
;cert = stunnel.pem
;key = stunnel.pem
; Some performance tunings
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
; Workaround for Eudora bug
;options = DONT_INSERT_EMPTY_FRAGMENTS
; Authentication stuff
;verify = 2
; Don't forget to c_rehash CApath
;CApath = certs
; It's often easier to use CAfile
;CAfile = certs.pem
; Don't forget to c_rehash CRLpath
;CRLpath = crls
; Alternatively you can use CRLfile
;CRLfile = crls.pem
; Some debugging stuff useful for troubleshooting
;debug = 7
;output = stunnel.log
; Use it for client mode
;client = yes
; Service-level configuration
;service = Stunnel-Client
;[pop3s]
;accept = 995
;connect = 110
;[imaps]
;accept = 993
;connect = 143
client = yes
debug = debug
[pop3s]
accept = 127.0.0.1:1109
connect = pop.gmail.com:995
[smtps]
accept = 127.0.0.1:40
connect = smtp.gmail.com:465
;
;[ssmtp]
;protocol=smtp
;accept = localhost:30
;connect = smtp.gmail.com:25
;[https]
;accept = 443
;connect = 80
;TIMEOUTclose = 0
; vim:ft=dosini
I did this a couple of months ago, so I might have left out something, if you find that something does not work, please mention it in the comments. This set-up has been working without any glitches scince I have set it up, but I was really disappointed with the fact that it is impossible to connect the TFS directly to a secured SMTP server, and I could not event directly forward mail to the Gmail servers from the virtual SMTP server.