api ile mail göndermek istiyorum fakat hata alıyorum
[HttpPost("sifresifirla")]
public void sifresifirla(string gelenmail)
{
MailMessage msg = new MailMessage();
msg.Subject = "Asp.Net Send Mail";
msg.From = new MailAddress("bodybookcomtr@gmail.com", "Görünen Ad");
msg.To.Add(new MailAddress("bodybookcomtr@gmail.com", "Görünen Ad"));
msg.Body = "Mesajınız... <br>" + msg.From.Address;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
// Host ve Port Gereklidir!
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
// Güvenli bağlantı gerektiğinden kullanıcı adı ve şifrenizi giriniz.
NetworkCredential AccountInfo = new NetworkCredential("bodybookcomtr@gmail.com", "parolam");
smtp.UseDefaultCredentials = false;
smtp.Credentials = AccountInfo;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(msg);
}hata
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptio nPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at
at System.Net.Mail.MailCommand.CheckResponse(SmtpStat usCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at webapi.Controllers.KullaniciController.sifresifirl a(String gelenmail) in /Users/macbook/Desktop/Yazılım Çalışmalarım/Backend/17 MART/webapi/Controllers/KullaniciController.cs:line 38
at Microsoft.Extensions.Internal.ObjectMethodExecutor .<>c__DisplayClass33_0.<WrapVoidMethod>b__0(Objec t target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMeth odExecutor.VoidResultExecutor.Execute(IActionResul tTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.Controller ActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceIn voker.<InvokeFilterPipelineAsync>g__Awaited|20_0(R esourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceIn voker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceIn voker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<I nvoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMi ddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddlewa re.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.I nvoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptio nPageMiddleware.Invoke(HttpContext context)