Closed duyanming closed 3 years ago
You need to also set AllowUnsecureAuthentication
to true if you aren't using a secure session.
var options = new SmtpServerOptionsBuilder()
...
.Endpoint(builder =>
builder
.Port(465, false)
.AllowUnsecureAuthentication(true))
.Build();
thank you
System.NotSupportedException HResult=0x80131515 Message=The SMTP server does not support authentication. Source=MailKit StackTrace: at MailKit.Net.Smtp.SmtpClient.d__69.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MailKit.Net.Smtp.SmtpClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)
at MailKit.MailService.Authenticate(Encoding encoding, String userName, String password, CancellationToken cancellationToken)
at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken)
at AnnoStmpServer.SampleMailClient.Send(String from, String to, String subject, String user, String password, MimeEntity body, Int32 count, Boolean useSsl) in D:\project\demo\Experiment\net5\aspnetcore5\AnnoStmpServer\SampleMailClient.cs:line 37
at AnnoStmpServer.Program.Main(String[] args) in D:\project\demo\Experiment\net5\aspnetcore5\AnnoStmpServer\Program.cs:line 44
此异常最初是在此调用堆栈中引发的: MailKit.Net.Smtp.SmtpClient.AuthenticateAsync(System.Text.Encoding, System.Net.ICredentials, bool, System.Threading.CancellationToken) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.GetResult() MailKit.Net.Smtp.SmtpClient.Authenticate(System.Text.Encoding, System.Net.ICredentials, System.Threading.CancellationToken) MailKit.MailService.Authenticate(System.Text.Encoding, string, string, System.Threading.CancellationToken) MailKit.MailService.Authenticate(string, string, System.Threading.CancellationToken) AnnoStmpServer.SampleMailClient.Send(string, string, string, string, string, MimeKit.MimeEntity, int, bool) (位于 SampleMailClient.cs 中) AnnoStmpServer.Program.Main(string[]) (位于 Program.cs 中)