1
Follow the email sending code, The error reported is in accessing with google SMTP.
StringBuilder conteudo = new StringBuilder();
conteudo.Append("O Srº(ª) " + "<b>" + txtNome + "</b>" + " entrou em contato pelo site no dia " + DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "hrs" + "<br /><br />");
conteudo.Append("<b>" + "Nome do contato: " + "</b>" + txtNome + "<br />");
conteudo.Append("<b>" + "Email: " + "</b>" + txtEmail + "<br />");
conteudo.Append("<b>" + "Telefone: " + "</b>" + txtTelefone + "<br />");
conteudo.Append("<b>" + "Tipo do serviço: " + "</b>" + ddlServico + "<br />");
conteudo.Append("<b>" + "Mensagem: " + "</b><br />" + txtMensagem);
MailMessage msg = new MailMessage(rnConfiguracoes.emailFrom, rnConfiguracoes.emailTo);
msg.Subject = rnConfiguracoes.nomeDoSite;
msg.SubjectEncoding = Encoding.Default;
msg.Body = conteudo.ToString();
msg.BodyEncoding = Encoding.Default;
msg.IsBodyHtml = true;
msg.CC.Add(rnConfiguracoes.emailCC);
msg.Bcc.Add(rnConfiguracoes.emailBCC);
var smtpClient = new SmtpClient(rnConfiguracoes.emailSmtp);
smtpClient.EnableSsl = true;
smtpClient.Port = 587;
smtpClient.Credentials = new System.Net.NetworkCredential(rnConfiguracoes.emailLogin, rnConfiguracoes.emailSenha);
try
{
smtpClient.Send(msg);
return "Mensagem enviada com sucesso. Agradecemos seu contato.";
}
catch (Exception ex)
{
return ex.StackTrace;
}
Which error?
– user28595
And what’s the mistake, young man?
– Jéf Bueno
Google’s SMTP is preventing these connections. Enter the settings and trigger the release of external sending.
– Andre Mesquita
You have a problem sending the email, Where do I release this Andre? on my own account?
– Danny Souza
I’m looking where I saw this. It was in a newly created account.You did not receive any notification in the gmail account indicating that there was an attempt to send by an external agent?
– Andre Mesquita
I created it almost a year ago, I’m taking Stacktrace’s mistake to command. one minute!!
– Danny Souza
Follow the error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
– Danny Souza
@Dannysouza new google accounts comes with Login for less secure applications disabled (this includes using SMTP with password). Either the user releases this in the account control panel, or rather, make your application direct the user to a XOAUTH authentication, so that he authorizes your application to access the account, and generating the access token to SMTP.
– Bacco
Denny Souza, I did a search and I saw that I already had a person who asked about the same error/ problem that you are having here in the stack and from what I saw it seems that managed to solve the problem, The link is here > http://answall.com/questions/90462/o-server-smtp-requires-a-connected%C3%A3o-secure-or-the-client-n%C3%A3o-has-been-authenticated I hope you can now solve your problem, and don’t forget to classify the answer as solved later. Good Luck.
– Viniam