Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. SMPT server not sent an Email to gmail or yahoo mails

SMPT server not sent an Email to gmail or yahoo mails

Scheduled Pinned Locked Moved ASP.NET
csharpcomsysadminsecurityhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muhammad Fahim Baloch
    wrote on last edited by
    #1

    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

    R J P 3 Replies Last reply
    0
    • M Muhammad Fahim Baloch

      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

      R Offline
      R Offline
      Rajesh Buddaraju
      wrote on last edited by
      #2

      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[^]

      1 Reply Last reply
      0
      • M Muhammad Fahim Baloch

        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

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Muhammad Fahim Baloch

          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

          P Offline
          P Offline
          phani sv
          wrote on last edited by
          #4

          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);

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups