Asked by:
How to resolve issues on SMTP mail send

Question
-
User-218090889 posted
I have this code to send email to user when user forget password, I am sending from my localhost pc. but the error I get says
Server does not support secure connections.
Now How do I resolve this so that it can work also on a Remote host?
below is my code
protected void eMailSubmit_Click(object sender, EventArgs e) { string username = ""; string password = ""; SqlConnection con = new SqlConnection(@"Data Source=My_DB;Integrated Security=False;"); SqlCommand cmd = new SqlCommand("SubmitEmail", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = TextBoxSubmiteMail.Text; con.Open(); SqlDataReader sdr = cmd.ExecuteReader(); { if (sdr.Read()) { username = sdr["Email"].ToString(); password = sdr["Password"].ToString(); } } con.Close(); if (username != TextBoxSubmiteMail.Text) { lblemailSubmit.Text = "The submitted eMail does not belong to this account, check the eMail and try again"; } else if (!string.IsNullOrEmpty(password)) { MailMessage msg = new MailMessage(); msg.From = new MailAddress("myMail@gmail.com"); msg.To.Add(TextBoxSubmiteMail.Text); msg.Subject = " Recover your Password"; msg.Body = ("Your Username is:" + username + "<br/><br/>" + "Your Password is:" + password); msg.IsBodyHtml = true; SmtpClient smt = new SmtpClient(); smt.Send(msg); lblemailSubmit.Text = "Username and Password Sent Successfully"; lblemailSubmit.ForeColor = System.Drawing.Color.ForestGreen; } }
below is my configuration code:
<configuration> <system.net> <mailSettings> <smtp deliveryMethod="Network"> <network host="smtp.gmail.com" port="25" enableSsl="true" defaultCredentials="false" userName="myMail@gmail.com" password="MyPassword" /> </smtp> </mailSettings> </system.net> </configuration>
Friday, August 11, 2017 12:59 AM
All replies
-
User2103319870 posted
port="25"Change the port no to either 465 or 587. You can take a look at the below articles
- https://productforums.google.com/forum/#!topic/gmail/nLCwVURZWx4;context-place=forum/gmail
- https://www.lifewire.com/what-are-the-gmail-smtp-settings-1170854
Friday, August 11, 2017 1:15 AM -
User-218090889 posted
Enzyme
port="25"Change the port no to either 465 or 587. You can take a look at the below articles
Enzyme
port="25"Change the port no to either 465 or 587. You can take a look at the below articles
I changed my port to 587, this is the error I got
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
Friday, August 11, 2017 1:35 AM -
User-335504541 posted
Hi Enzyme,
Enzyme
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication RequiredYou could refer to links below for solution to this error :
Best Regards,
Billy
Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Friday, August 11, 2017 3:29 AM -
User-1377768212 posted
Hi,
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication RequiredYou can refer my blog :
http://www.c-sharpcorner.com/blogs/smtp-server-requires-a-secure-connection1
Other Reference :
http://www.c-sharpcorner.com/UploadFile/2a6dc5/how-to-send-a-email-using-Asp-Net-C-Sharp/
Friday, August 11, 2017 5:50 AM -
User-398246787 posted
remove the whole network strings in the web.config file,
and manually add these credentials in the SMTP clientobject.
and try sending the email.
use port 587
since gmail is free, google may sometimes refuse connection
Friday, August 11, 2017 7:58 PM -
User1341756031 posted
Try Less secure apps
Log in to your Gmail account through a web browser and enable access through less secure apps . Less secure apps can make your account more vulnerable, Google will automatically turn this setting off if it's not being used. However, bypass this security setting with a configuration tweak within your Google Email Account .
How "more secure apps" help to protect your account?
Which level of access you're giving the client before you connect your Account.
Client access only a relevant part of your Account, like your email or calendar.
Connect your Google Account to the client without exposing your password.
Disconnect your Google Account from the client at any time.Tuesday, July 30, 2019 6:02 AM