The SMTP server requires a secure connection or the client was not authenticated.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praveenb000
    New Member
    • Aug 2008
    • 21

    The SMTP server requires a secure connection or the client was not authenticated.

    i write code for sending mail to client's given email addresses.

    But Im getting following error message

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: dnsgem.org ESMTP MailEnable Service, Version: 0--2.53 denied access at 09/30/09 08:49:39


    this is the code i written for sending mail

    Code:
        Public Sub SendMail(ByVal Efrom As String, ByVal EReceiver As String, ByVal subject As String, ByVal body As String, ByVal attachmentFileName As String)
    
     Try
    
                Dim ToAddress As String
    
                ToAddress = "kitsinda@gmail.com"
    
                Dim Msg1 As New MailMessage(Efrom, ToAddress)
                Msg1.Subject = subject
                Msg1.Body = body
                Msg1.Priority = MailPriority.Normal
                Msg1.IsBodyHtml = True
    
                If (attachmentFileName <> "") Then
                    Msg1.Attachments.Add(New Attachment(attachmentFileName))
                End If
    
                Dim client1 As New SmtpClient(SMTPSERVER, 25)
                client1.Credentials = New System.Net.NetworkCredential(Me.MailUsername, Me.MailPassword)
                client1.Send(Msg1)
     Catch ex As SmtpException
                Throw New Exception(ex.Message)
    
            Finally
    
            End Try
    
    End Sub
    I don't know where i made mistake.

    this is the url for

    http://kitseducation.n et/innerpages/enquiry.aspx,

    Please give me solution for the above problem

    Thanks In Advance.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You need to contact the company hosting the SMTP server and find out what port to connect on.

    Right now you're connecting on the default port (25) but from my experience secured SMTP servers don't use this port.

    -Frinny

    Comment

    • blck
      New Member
      • Feb 2012
      • 4

      #3
      Hi praveenb000,

      I also have the problem. Do you solved? Can you help me.

      Comment

      • PsychoCoder
        Recognized Expert Contributor
        • Jul 2010
        • 465

        #4
        You need to use the proper port (looks like you're sending it to GMail) so add this to your SmtpClient:

        Code:
        Dim client1 As new SmtpClient("smtp.gmail.com");
        client1.Port = 587;
        client1.Credentials = new System.Net.NetworkCredential("myaccount@gmail.com", "mypass");
        client1.EnableSsl = true;

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          I included a code snippet for how to send an email through gmail in the Quick reference on how to send an email using .NET article.

          :)

          -Frinny

          Comment

          • blck
            New Member
            • Feb 2012
            • 4

            #6
            Hi,

            I tried however it aslo display error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: host5.vdconline .vn ESMTP MailEnable Service, Version: 5.51-- denied access at 02/04/12 04:08:41

            My code:
            Code:
            MailMessage msg = new MailMessage();
                    SmtpClient smtp = new SmtpClient("*.*.*.*", 25);        
                    msg.From = new MailAddress("admin@***");        
                    msg.To.Add(new MailAddress(TextBox1.Text));
                    msg.Subject = "Recover password";
                    msg.Body = "";
                    msg.IsBodyHtml = true;        
                                    
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;        
            
                    smtp.EnableSsl = true;  
            
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential("admin@***", "*****");              
            try
                    {
                        smtp.Send(msg);
                        Label3.Text = "Email sent successfully";
                    }
                    catch (Exception ex)
                    {
                        Label3.Text = ""+ex.Message;
                    }
            Please help me!
            Thanks in advance!

            Comment

            • PsychoCoder
              Recognized Expert Contributor
              • Jul 2010
              • 465

              #7
              For starters you're still using port 25, GMail requires port 587. Given the last part of the error message it's saying you're using the wrong username/password combination.

              Are you sending email through Gmail or a different host?

              Comment

              • blck
                New Member
                • Feb 2012
                • 4

                #8
                Hi,

                I checked all info. Username and password of my webmail are correct.
                I rented a host. Port outgoing of host is 25.
                Particularly, before hosting, I sended email from this host to my gmail by control from my computer. It is successful. However, after hosting, it has error. I don't understand.
                Alternatively, I sended email through gmail. It is successful.

                Please help me! Thanks.

                Comment

                Working...