hi i have an error, i have written a code to send an email. the email was sent to private email address like info@yourdomain.com but the email was not sent to any "gmail or yahoo mail address." when i tried to sent an email to gmail or yahoo account the following error occurs, "Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server." here is my code : protected void SendEmail() { SmtpClient smtpClient = new SmtpClient("mail.mydomain.com", 25); MailMessage Msg = new MailMessage(); //------for Email Data---------------------------------- Msg.To.Add(TxtEmail .Text .Trim ()); Msg.From = new MailAddress("tehnical@mydomain.com"); Msg.IsBodyHtml = true; //----Get Max userid------------------------------ string strConnection = ConfigurationManager.ConnectionStrings["AIGamesConnectionString"].ConnectionString; SqlConnection MaxUserIdCon = new SqlConnection(strConnection); MaxUserIdCon.Open(); string StrMaxUserId = "select max(id) as Id from users"; SqlCommand MaxUserIdComm = new SqlCommand(StrMaxUserId, MaxUserIdCon); SqlDataAdapter MaxUserIdDa = new SqlDataAdapter(MaxUserIdComm); DataSet MaxUserIdDs = new DataSet(); MaxUserIdDa.Fill(MaxUserIdDs); MaxUserIdCon.Close(); int MaxUserId=1; if (MaxUserIdDs.Tables [0].Rows.Count >0) { MaxUserId = Convert.ToInt32(MaxUserIdDs.Tables [0].Rows [0]["Id"].ToString ()); } //------------------------------------------------ StringBuilder bodyMsg = new StringBuilder(); bodyMsg.Append("Thank you for creating your account.\n\nPlease follow this link to activate: "); bodyMsg.Append("
Activate Your Account"); Msg.Body = bodyMsg.ToString(); //authentication-------------------------------------------------------------------------------- SmtpClient mySmtpClient = new SmtpClient(); System.Net.NetworkCredential myCredential = new System.Net.NetworkCredential("tehnical@mydomain.com", "password"); mySmtpClient.Host = "mail.mydomain.com"; mySmtpCl