我有一个不需要身份验证来发送电子邮件的 smtp 服务器,我使用 C# 的 SmtpClient:
message.From = new MailAddress(appSettings.senderMail);
message.Subject = appSettings.mailsubj;
message.Body = appSettings.mailbody;
Attachment attach = new Attachment(sOutput);
message.Attachments.Add(attach);
SmtpClient client = new SmtpClient(appSettings.SMTP, appSettings.smtpSvPort);
if (bSMTPAuth)
{
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(strSMTPUsername, strSMTPPAssword);
}
client.SendCompleted += this.SendCompletedCallback;
message.To.Clear();
message.To.Add(clientEmail);
client.Send(message);
它可以在不进行身份验证的情况下发送,但是当我尝试进行身份验证时,即使我使用了错误的密码,邮件仍然会被发送,我想看看身份验证是否有效..当我使用错误的用户/密码连接时抛出错误.