Click here to Skip to main content
14,601,062 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am developing website in,in that page Code was given below it works Localhost only not in Web server.What can i do?? Please Anyone can help me?

It shows an error,
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

What I have tried:

My Code is,
 protected void btnSubmit_ServerClick(object sender, EventArgs e)
        SmtpClient client = new SmtpClient();
        client.Host = ""; //Set your smtp host address  
        client.Port = int.Parse("587"); // Set your smtp port address  
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.Credentials = new NetworkCredential("", "****"); 
        client.EnableSsl = true; // Set SSL = true  
        MailMessage message = new MailMessage();
        message.To.Add(""); // Add Receiver mail Address  
        message.From = new MailAddress(""); // Sender address  
        message.Subject = "EnQuiry From Customer";

        message.IsBodyHtml = true; //HTML email  
        message.Body = txtsubject.Text + "<br/>" + txtName.Text + "<br/>" + txtMobileNo.Text;

        Response.Write("<script>alert('Submitted Successfully');</script>");
Updated 6-Feb-19 6:25am
Richard MacCutchan 6-Feb-19 12:20pm
You should not be using the gmail server for this (Google has rules), but your local smtp service.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The most common issues I have seen with gmail is

1. Google does not recognize the connection being used for the particular email account being used. The best thing to do is to go to their Login Activity page and tell them basically that "yes, that was me"
Sign in - Google Accounts[^]

2. Google by default blocks SMTP access under the premise that it is less secure. There is an option to allow "Less Secure Apps" which will allow SMTP access
Account settings: Your browser is not supported.[^]
Flower@12 6-Feb-19 12:33pm
Thank you sir 1st one is working now

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

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