SMPT server not sent an Email to gmail or yahoo mails
-
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
-
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
This is some what related to the smtp permissions issue. find the following forum may be it will helpfull. http://forums.iis.net/p/1157046/1901343.aspx[^]
-
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
You created 2 SmtpClient Objects, you must of mixed up the object that sends You really should structure your code better, because that was a hard read. I don't see why you would build your message body via sql in the middle of your email function, Why not build your html message first, and then pass the message to the smtp function, in which you set your parameters, and send the message. You didn't attach the message (msg) to the smtp object, sloppy code will produce errors, that you can't see.
-
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
Try this: MailMessage Msg = new MailMessage(); Msg.To.Add( new MailAddress(TxtEmail .Text .Trim ())); Msg.From = "tehnical@mydomain.com"; Msg.IsBodyHtml = true; Msg.Subject = "Login Details"; SmtpClient smtp = new SmtpClient(); smtp.Host = "mail.mydomain.com"; smtp.Port = 1234; smtp.EnableSsl = GmailSSL; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("tehnical@mydomain.com","password"); smtp.Send(Msg);