You need hard work to get Lucky!

They are ill discoverers that think there is no land, when they can see nothing but sea.

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

Posted by zeemalik on February 18, 2009

Problem: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. c25sm1228430ika.11

 

 

Solution:

 

 

Public Shared Sub SendEmail()

 

 

    Dim Message As New Net.Mail.MailMessage()

 

    Dim FromEmail As New Net.Mail.MailAddress(“From Email Address”)

    Message.From = FromEmail

    Message.To.Add(“To Email Address”)

 

 

    Message.Subject = “Subject of the Email”

    Message.Body = “Body of the Email”

    ‘Message.SubjectEncoding = System.Text.Encoding.UTF8

    ‘Message.BodyEncoding = System.Text.Encoding.UTF8

    ‘Message.IsBodyHtml = False

    ‘Message.Priority = Net.Mail.MailPriority.High

 

    Dim SmtpClient As New Net.Mail.SmtpClient(“smtp.YourEmailServer.com”, PortNo eg: 587 for gmail )

    SmtpClient.EnableSsl = True

    ’smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network

    ’smtp.UseDefaultCredentials = False

 

SmtpClient.Credentials = New Net.NetworkCredential(“YourEmailAddress”, “YourEmailPassword”)

 

    SmtpClient.Send(Message)

 

 

End Sub

 

Note: An important point to note is that you have to set the EnableSSl to True before you set the NetWork Credentials of your SMTP client.

AddThis Social Bookmark Button
View zeeshan malik's LinkedIn profileView zeeshan malik’s profile

2 Responses to “The SMTP server requires a secure connection or the client was not authenticated”

  1. Thanks for sharing!

  2. rabi said

    i m a .net developer.
    i’m trying to send mail from asp application.
    i’m using visual studio 2008 And C#.

    I’m getting error “The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication required”

    My code is
    MailMessage mail = new MailMessage();

    mail.To.Add(TextTo.Text);

    mail.From = new MailAddress(TextFrom.Text);

    mail.Subject = TextSbj.Text;

    mail.Body = TextBody.Text;

    SmtpClient smtp = new SmtpClient();

    smtp.Host = “in.smtp.mail.yahoo.com “;
    smtp.Port = 587;
    //smtp.EnableSsl = true;
    smtp.UseDefaultCredentials = false;

    smtp.Credentials = new System.Net.NetworkCredential(“username”, “password”);

    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

    smtp.Send(mail);

    anyone help
    thanx

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>