Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
This generally happens when you try login from different time zone or IP Address Computer. Your production server and the mail id you have used both are in different time zone. Choose either of these two solutions:
1) Log in to production server via remote access, and sign in to gmail once with your credentials. They will ask for the confirmation, confirm it and log out.
Or 2) log in gmail to your local computer, Follow this Link and choose review this activity and take proper actions.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?
First check for gmail's security related issues. You may have enabled double authentication in gmail. Also check your gmail inbox if you are getting any security alerts. In such cases check other answer of @mjb as below
Below is the very general thing that i always check first for such issues
client.UseDefaultCredentials = true;
set it to false.
Note @Joe King's answer - you must set client.UseDefaultCredentials before you set client.Credentials
the SMTP server requires a secure connection or the client was not authenticated. The server response was 5.5.1, Authentication required
Check your gmail account and turn on "Acess for less secure apps"
Set
client.UseDefaultCredentials = false;
beforeclient.Credentials = new NetworkCredential("Sender email", "Sender email password");
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. In html
Your errors...
The SMTP server requires a secure connection or the client was not authenticated.
- Are you running on HTTPS?
- You didn't provide proper authentication. You do realize you need your real email address (the
username
attribute; you're using Gmail, so you have to provide your Gmail address) and your real password to send emails from your account, right? (That includes thefrom
field.) Gmail also has some extra complications. See this post on how to send emails from Gmail.
Mailbox name not allowed. The server response was: Envelope FROM 'hi@gmail.com' email address not allowed.
You tried to send an email from "hi@gmail.com". Do you think it will work? Let's pretend your email is bob@gmail.com
. If what you attempted didn't result in an error, that means that I can send an email from your email without your permission! So no, that rightly shouldn't work.
All else aside, please don't try to send emails from the client-side. You realize that if you publish your app everyone can see your email address
and password, right?
Related Topics
Parameters Passed by Reference Come Back Garbage Using P/Invoke
When to Use Cast() and Oftype() in Linq
Serialize Class Containing Dictionary Member
How Using Try Catch for Exception Handling Is Best Practice
Error: "Cannot Modify the Return Value" C#
Effective Way to Find Any File's Encoding
Deserializing JSON into an Object
Generating an Xml Serialization Assembly as Part of My Build
How to Check If an Object Is Nullable
Draw Semi Transparent Overlay Image All Over the Windows Form Having Some Controls
How to Autheticate to Ibm Mq C# with Tls-Certificate
Show a Form Without Stealing Focus
How to Write a JSON File in C#
How to Rethrow Innerexception Without Losing Stack Trace in C#
Intersection of Multiple Lists with Ienumerable.Intersect()
How to Load Dll 'Sqlite.Interop.Dll'