title: .NET SMTP mail - error = helo command rejected need fully-qualified hostname
body: <p>I am trying to send email in a .NET console application. I have an SMTP server with i.P. address X.X.X.X (sanitized to protect the innocent).</p>
  
  <p>The SMTP server has been set up (the relay configured) to allow email from the server that is hosting the .NET console app, and send that email to the outside world.</p>
  
  <p>I have tested this with telnet from the server hosting the console app. I successfully sent an email with telnet console from the server hosting the console app using the SMTP server's I.P. address. There is no authentication required when using telnet. I have not been given any connection credentials.</p>
  
  <p>But when I try to do it in the .NET app, I get the following error:</p>
  
  <blockquote>
    <p>Syntaz error, command unrecognized. The server response was: : Helo command rejected: need fully-qualified hostname</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>string mailMessagetest = "test";
          string subjecttest = "test";
          List&lt;string&gt; recipienttest = new List&lt;string&gt;();
          recipienttest.Add("me@mydomain.com");
  
          utility.SendMail(recipienttest, subjecttest, mailMessagetest);
  </code></pre>
  
  <p>Here is the function SendMail:</p>
  
  <pre><code>        public static void SendMail(List&lt;string&gt; recipient, string subject, string message)
      {
          MailMessage mailMessage = new MailMessage();
          mailMessage.From = new MailAddress("myfriend@mydomain.com");
  
          foreach (string to in recipient)
          {
              mailMessage.To.Add(to);
          }
  
          mailMessage.Subject = subject;
          mailMessage.Body = message;
  
          SmtpClient client = new SmtpClient();
          client.Host = "X.X.X.X";
          client.Port = 25;
          client.Send(mailMessage);
      }
  </code></pre>