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
About these ads

18 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

  3. Danish said

    Thanks for helping out the stated issue, i am using the code and it works perfectly fine ..

    cheers

  4. Tony said

    Thanks very much for sharing! Works great!

  5. This is a time I visit your blog without leaving comments, thank you for your articles are always so interesting!

  6. Sandeep said

    Thanks alot its working :) :) :)

  7. although I squander virtually all of my working day on the net participating in games like facebook poker or petville, I still like to take some spare time to research a few websites occasionally and I’m content to report this newest article is really more or less good quality and extremely superior than 1 / 2 the other poor quality trash I read today , anyways i’m off to have fun with a few hands of facebook poker

  8. Arpit Srivastava said

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

    SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587);
    client.EnableSsl = true;
    client.UseDefaultCredentials = true;

    client.Send(msg);

  9. abhishek said

    It helps:)

  10. Sangram Patil said

    Very nice program. After trying for 2 days I got this and it works fine. THANKS A LOT

  11. Dhruv Patel said

    Nice post.

    I actually did not copy your code, but your last line helped me solve my problem.

    Thanks again.

  12. Website said

    Website…

    The SMTP server requires a secure connection or the client was not authenticated « You need hard work to get Lucky!…

  13. Jitender said

    Solved my problem…….

  14. All About Mail…

    [...]The SMTP server requires a secure connection or the client was not authenticated « You need hard work to get Lucky![...]…

  15. Mohamed_EG said

    Thanks alot! You are a live saver !

  16. vineeth vijayan said

    Thanks a lot . . .my problem solved

  17. Sanjay said

    Thanks for posting the code & following note :

    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.

    It helped me a lot.

  18. Thank you for some other fantastic article. Where else could anyone get that kind of information in such a perfect approach of writing? I have a presentation next week, and I’m at the search for such information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: