none
SMTP error: The server response was: 5.7.1 Client was not authenticated ()

    Question

  • I'm setting up a test environment for a mult-tiered TFS 2008 setup (all on Win Server 2008, one AD/DC, one Data Tier and one Web Tier).  One thing we have in production is a custom email web service and I am setting this up in the test environment.  I'm using Exchange Server 2007 (the 32-bit trial version) for mail.  I have successfully setup the Exchange Server and I can send/receive email between different accounts on the different machines in the setup.  Also, I can successfully setup and use the custom Email web service (it responds to the WorkItemChanged event) but this is the problem: I can only send mail if I explicitly enter the User and Password for one of the accounts.  In the production enviroment this is not necessary as it is able to authenticate without needing the TFS user's info.  When I do not hard-code a valid account, the I get this error:

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated () "Exchange Server 2007"

    Below is the code in the Web Service for actually creating and sending the mail:

    SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"]);
    if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["SMTPPassword"]))
    {
        smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["SMTPUser"],ConfigurationManager.AppSettings
                                           ["SMTPPassword"]);
    }
    Logger.Log("Sending email....");
    smtp.Send(mail);
    Logger.Log("Email successfully sent.");

    This all works as long as I give the acutal values for an account user in the web.config app settings (as used in the if statement).  But I get the error above if I leave these values blank.

    How do you setup Exchange Server 2007 and/or the Web Tier to authenticate emails like this?
    Wednesday, January 27, 2010 7:36 PM

Answers

  • Figured it out.  I'm new to Exchange Server, so it woud've been easy if I knew what to do:

    In the Exchange Management Console, under the Server Configuration node, select Hub Transport and the name of the server.  In the Receive Connectors pane, open either of the Recive Connectors (my default installation created 2) or you can create a new one just for TFS (I also tried this and it worked).  For any of these connectors, open Properties and on the Permission Groups tab ensure that Anonymous Users is selected (it's not by default). 

    Would be nice to have this kind of thing in the TFS Admin chm file.
    • Marked as answer by sdfsda Thursday, January 28, 2010 4:34 PM
    Thursday, January 28, 2010 4:34 PM

All replies

  • Hi sdfsda,

    If you do not specify the user/pwd of the SmtpClient , SmtpClient  will use the app pool identity account to connect to SmtpHost.

    So there are 2 ways to solve it.

    1 If the app pool identity is a domain account, you can give the account the right to send mail

    2 Change the  app pool identity to a domain account which has right to send mail.


    Best regards,
    Ruiz
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    Thursday, January 28, 2010 3:05 AM
    Moderator
  • No luck.  The app pool identity is the [domain]\tfsservice and I did give it an email and a mailbox, just as the other users.  I get the same error.

    I tried changing the app pool to other users that do have all the right permissions and that  I can successfully use for emails via Outlook, etc.  I produce an extensive log from the web service dll and there are no permissions errors, etc. reported.  Everything works fine until the very last line of code which is to send the email, and then the error. 

    Basically, this looks like an issue with Exchange Server 2007 allowing a Web Service (or the internet?) to send emails.  I can't find any settings to fix this.

    Also, I did run the command line tool to grant anonymous access per the Exchange Server help.  This had no effect.
    Thursday, January 28, 2010 1:33 PM
  • Figured it out.  I'm new to Exchange Server, so it woud've been easy if I knew what to do:

    In the Exchange Management Console, under the Server Configuration node, select Hub Transport and the name of the server.  In the Receive Connectors pane, open either of the Recive Connectors (my default installation created 2) or you can create a new one just for TFS (I also tried this and it worked).  For any of these connectors, open Properties and on the Permission Groups tab ensure that Anonymous Users is selected (it's not by default). 

    Would be nice to have this kind of thing in the TFS Admin chm file.
    • Marked as answer by sdfsda Thursday, January 28, 2010 4:34 PM
    Thursday, January 28, 2010 4:34 PM
  • Yes it works like a charm. Thanks sdfsda (by the way very original user name :) ).

     

    Now I can receive emails from the internet, yessssssssss.

    Friday, December 30, 2011 1:08 AM
  • Glad it was useful.
    Saturday, December 31, 2011 6:45 PM