我的vb.net代码使用Mailkit通过我的ionos服务器发送电子邮件。
Dim cl As New SmtpClient
cl.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications
cl.Connect(email_host, 25, MailKit.Security.SecureSocketOptions.None)
cl.Send(de_mimemessage)
代码正常运行,但是偶尔(也许每几百次)我在代码的连接部分收到以下错误:
需要验证
我该怎么做才能使此错误永远不会发生?
这是堆栈跟踪...
(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.<MailFromAsync>d__88.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MailKit.Net.Smtp.SmtpClient.<SendAsync>d__99.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MailKit.Net.Smtp.SmtpClient.Send(FormatOptions options, MimeMessage message, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.MailTransport.Send(MimeMessage message, CancellationToken cancellationToken, ITransferProgress progress)
at marketing_email_plus_removals.send_email(Boolean in_test, String in_email, String in_postcode) in E:\kunden\homepages\14\d650565413\www\marketing_email_plus_removals.aspx.vb:line 547
答案 0 :(得分:0)
当您收到“需要身份验证”异常时,这意味着服务器将不允许您发送该消息,除非您进行身份验证。
发生这种情况时,请致电:
cl.Authenticate ("username", "password");