Click here to Skip to main content
12,452,083 members (25,298 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SMTP Mail
here is my code:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.Subject = "Nici un Clinet valabil pentru reparare";
                    message.From = new System.Net.Mail.MailAddress("");
                    message.Body = "Nu mai sunt clienti la care mecanicii sa lucreze";
                    string sendEmailsFrom = "";
                    string sendEmailsFromPassword = "my_invisible_password";
                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("", 587);
                    smtp.EnableSsl = true;
                    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtp.Credentials = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword);
                    smtp.Timeout = 20000;

And my error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

What is the problem? i can't see it and can't find a solution on google.

Sas Gabriel
Posted 12-Nov-12 10:48am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to set
UseDefaultCredentials = false;
first and after that set the credentials you want to use

Credentials = new NetworkCredential("", "my_invisible_password");

Also make sure you can login from with your username and password from the page.

Good luck,
Gabriel Sas 12-Nov-12 17:04pm
also the password wasn't the good one, thanks
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Also please be aware that google will block you from logging in when you do to much connection attempts.

I always use a local email server for development:[^]
It's free. You can simply configure it and run it on your computer, connecting to localhost:2525.
Please be sure to also turn down the ban-option ("auto-ban") of this one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100