MailKit使用我的Exchange Server身份验证自托管的电子邮件?
从本质上讲,我有一个带有Exchange和Active Directory等的本地邮件服务器。我试图在C#中使用MailKit进行身份验证电子邮件,但每次都会遇到身份验证错误。我尝试使用“ int \ name”,“ password”或“ name”,“ password”或“地址”,“密码”等多种不同的方法来使用client#Authentication
public Email()
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress("", "[email protected]"));
message.To.Add(new MailboxAddress("", "[email protected]"));
message.Subject = "test email";
message.Body = new TextPart("plain")
{
Text = @"test"
};
var client = new SmtpClient();
client.Connect("my.mailserver.com", 25, MailKit.Security.SecureSocketOptions.StartTls);
client.Authenticate("[email protected]", "mypassword");
client.Send(message);
client.Disconnect(true);
}
。 https://i.sstatic.net/lpt6g.png“ rel =“ nofollow noreferrer”>
Essentially, I have a local mail server with exchange and active directory and etc.. I'm trying to authenticate an email with Mailkit in C# but I get an authentication error every single time. I've tried many different ways of using client#Authenticate by using "int\name", "password" or "name", "password" or "address", "password" etc. Here's my code:
public Email()
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress("", "[email protected]"));
message.To.Add(new MailboxAddress("", "[email protected]"));
message.Subject = "test email";
message.Body = new TextPart("plain")
{
Text = @"test"
};
var client = new SmtpClient();
client.Connect("my.mailserver.com", 25, MailKit.Security.SecureSocketOptions.StartTls);
client.Authenticate("[email protected]", "mypassword");
client.Send(message);
client.Disconnect(true);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复了每个人。希望将来有人可以从中受益。
通过使用端口587而不是25,还使用FQDN \用户名来修复它
Fixed it everyone. Hopefully someone can benefit from this in the future.
Fixed it by using port 587 instead of 25, and also by using fqdn\username