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);
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With