How Tfs sends emails - testing the smtp pipes
If you are having trouble getting Tfs to send emails, one thing to test is connectivity and permission to send. Sometimes the mail server will refuse to accept email if the sending account doesn't itself have a mailbox, or if the "from" address doesn't match the account that is connecting to the server. Log in as the service account, create a console application, copy and paste the following code, replace the first three strings with the appropriate values, compile and run it. If it is a problem connecting to the mail server, you should get a good error message printed out. Otherwise you should see the email appear in your inbox.
using System;
using System.Net;
using System.Net.Mail;
namespace MailSender
{
class Sender
{
public static void Main(string[] args)
{
try
{
string Host = "myEmailServer";
string FromAddress = "serviceAccount@somewhere.com";
string ToAddress = "me@somewhere.com";
SmtpClient client = new SmtpClient(Host);
MailMessage mm = new MailMessage(FromAddress, ToAddress);
mm.Body="TestBody";
mm.Subject="TestSubject";
client.UseDefaultCredentials = true;
mm.BodyEncoding = System.Text.Encoding.UTF8;
client.Send(mm);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.ReadLine();
}
}
}